December 24, 2009 at 11:02 AM
Null pointer exceptions are errors thrown by the Java compiler when we use a variable that hasn't been defined or access a field or invoke a method of a null object.
You can handle it by using null object like this:
String f = null ;
System.out.println("Length is:"+ f.length());
If you run the above code, you will not get the Exception as we have used the null object otherwise you will get the Exception.