Note of 《thinking in java》3

3. Controlling Program Flow

  1. An rvalue is any constant, variable, or expression that can produce a value, but an lvalue must be a distinct, named variable.
  2. Whenever you manipulate an object, what you are manipulating is the reference, so when you assign "from one object to another", you are actually copying a reference from one place to another.
  3. When you create a Random object, because no arguments are passed during creation, Java uses the current time as a seed for the random number generator.
  4. The default behavior of equals() is to compare references. So unless you override equals() in your new class you won't get the desired behavior.
  5. Most of the Java library classes implement equals() so that it compares the contents of objects instead of their references.
  6. You can't use a non-boolean as if it were a boolean in a logical expression as you can in C and C++.
  7. Java has also added the unsigned right shift >>>, which uses zero extension: regardless of the sign, zeroes are inserted at the higher-order bits. This operator does not exist in C or C++.
  8. If you shift a char, byte, or short, it will be promoted to int before the shift takes place, and the result will be an int.
  9. Java has no "sizeof". Because all the data types are the same size on all machines.
  10. Don't be lulled into thinking everything is safe. If you multiply two ints that are big enough, you'll overflow the result.
  11. The only place a label is useful in Java is right before an iteration statement.
  12. The switch statement is a clean way to implement multiway selection.
  13. Casting from a float or double to an integral value always truncates the number.
  14. Math.random() never produces either 0.0 or 1.0.
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值