• -11 % 2 == -1, not 1
  • 2.00 – 1.10 = .89999… due to default use of double
  • 24 * 60 * 60 * 1000 * 1000 will overflow due to default use of integer, use 24L * 60 * 60 * 1000…
  • 0xcafebabe is negative with leftmost bit set
  • Sign extension is performed if the type of the original value is signed; zero extension if it is a char, regardless of the type to which it is being converted.
  • x ^= y ^= x ^= y is evaluated left to right and x is cached twice.
  • (true/false) ? x : y, watch for promotion from narrow type to wide type (e.g. char to int)
  • T x += i is x = (T)(x + i) with a hidden cast that might lop off digits, not x = x + i
  • “string1” + str2 == str3 is actually (“string1” + str2) == str3
  • 0x90 is of type int, not byte
  • <<=, >>= and >>>= use only the lower 5 bits (2 ^ 5 == 32)
  • a big double + 1 does not change the value
  • Double.POSITIVE_INFINITY + 1 equals the same
  • NaN != NaN
  • do not use compound assignment operators on short, byte, or char because it can perform narrowing primitive conversion
  • new Integer(1) < 2 is possible due to autounboxing
  • ms % 60*1000 == (ms % 60) * 1000
  • finally block always determines the return value
  • there is no dynamic dispatch for static method
  • null instanceof ??? == false
  • ((Class)null).staticMethod() is OK but Class.staticMethod() is better
  • All wrapper types (Integer, Long, Character..) are immutable
  • you must override hashCode whenever you override equals
  • 012 is octal, not integer
  • Math.abs returns negative for Integer.MIN_VALUE
  • Integer.MAX_VALUE – Integer.MIN_VALUE overflows
  • When a variable and a type have the same name and both are in scope, the variable name takes precedence
  • use(X.Y)null).Z to force a type name
  • A package-private method cannot be directly overridden by a method in a different package unless method is declared protected or public
  • drain process output stream while waiting for process to finish
  • Don't use THRead.interrupted unless you want to clear the interrupted status of the current thread
  • Converting an int or a long value to float, or a long value to double can result in loss of precision.
  • static member classes are preferable over nonstatic
  • having a derived class as an inner class is a bad idea
  • Collections.shuffle() is handy
  • Static members of a class cannot be serialized
  • Favor composition over inheritance due to danger of super class self use