Show Menu
Cheatography

Java Special Notes (OCA) Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

What's null?

null is default value for java object.
it is not a valid object instance
simply a value says ref variable not referring to an object currently.
thread ->s­tac­k->­fra­me(­method) ->v­ari­abl­e(i­den­tif­ier­,sy­mbolic name) on frame
null is just a value in the stack frame and no allocated memory on heap.

Java syntax for null

not to primitive
NullPo­int­Exc­eption when access instance member, ok to access static members
throw null will cause NullPo­int­Exc­eption
printed as null
object array default value is null

Dead code rule

Dead code only applies when compil­e-time constants are used
While Loops
will not compile if a false constant is used
for loop
will not compile if a false constant is used
if condit­ional
will compile regardless of constant, but a warning will appear for dead code
Switch statement
same as condit­ional but no warning
try/catch
catch block parameter order must go up in hierarchy order