3. Controlling Program Flow
- An rvalue is any constant, variable, or expression that can produce a value, but an lvalue must be a distinct, named variable.
- 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.
- 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.
- 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.
- Most of the Java library classes implement equals() so that it compares the contents of objects instead of their references.
- You can't use a non-boolean as if it were a boolean in a logical expression as you can in C and C++.
- 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++.
- 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.
- Java has no "sizeof". Because all the data types are the same size on all machines.
- Don't be lulled into thinking everything is safe. If you multiply two ints that are big enough, you'll overflow the result.
- The only place a label is useful in Java is right before an iteration statement.
- The switch statement is a clean way to implement multiway selection.
- Casting from a float or double to an integral value always truncates the number.
- Math.random() never produces either 0.0 or 1.0.