This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Is there anything like a "Rule of Thumb" or does anyone know of an easier way to learn which errors would result in a Runtime Error, and which would result in a Compiler Error? For example, using the dot-operator on null results in a Runtime Error; why wouldn't want the compiler take care of it? Thanx for answering,
The compiler will report any errors it can find, but it's not all that smart. It never knows the value that any variable contains, so it will always allow you to dereference a variable (as long as the compiler is sure the variable has been initialized to some value.) Similarly, it can check whether a type cast is plausible, but it can't check whether the cast will definitely succeed or not, so casts fail at runtime unless the compiler can prove that two types definitely can't be interconverted.