《Java Puzzlers》学习笔记

摘录每一个 Puzzle的总结 :

1.Test that your methods behave properly when passed negative,zero,and positive values for each numerical parameter.(传递正数、零和负数给每一个数字参数来测试你的方法是否运作正常)

2.Avoid float and double where exact answers are required; for monetary calculations,  use int, long, or BigDecimal.(对于答案要求很严格的地方避免使用float和double类型;对于货币计算,最好使用int、long或BigDecimal类型)

3.When working with large numbers, watch out for overflow—it's a silent killer.(对大数进行操作时谨防溢出)

4.Always use a capital el(L) in long literals, never a lowercase el(l).(为了便于区分,当标记long型值时永远使用大写的L,而不是小写的)

5.It is generally best to avoid mixed-type computations.(最好避免混合类型的计算)

6.If you can't tell what a program does by looking at it, it probably doesn't do what you want.(如果你不不知道程序是怎样运行的,那么它可能不会按你想的去做)

7.Do not assign to the same variable more than once in a single expression .(不要在一个单独的表达式中对同一个变量多次赋值)

8.Use the same type for the second and third operands in conditional expressions.(在条件表达式中,第二和第三个参数请使用同一种类型)

9.Do not use compound assignment operators on variables of type byte, short, or char.(不要将组合赋值号用在byte,short或char类上)

10.The + operator performs string concatenation if and only if at least one of its operands is of type String.(当且仅当+连接至少一个String类值时,+执行连接字符串操作)

每天看一点,待续……

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值