Sunday, January 10, 2010

Groovy Dereferencing Null Pointer Exceptions Step 13

The most annoying and most common error in Java is the Null Pointer Exception.

If you type:

def a=null
println a.size()
You will get a Null Pointer Exception

If you type
println a?.size(),

it will print null and not throw you a null pointer exception. This makes it a lot easier to check for null pointer exceptions.

(Step 14 Coming Soon)

0 comments: