本文主要是介绍《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类值时,+执行连接字符串操作)
每天看一点,待续……
这篇关于《Java Puzzlers》学习笔记的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!