Answers for "handle nullpointerexception in java"

0

nullpointerexception

public class MyClass{
	private Object iAmNull;//This is null by default
    private Object iAmInitialized=new Object();
    public void test(){
    	System.out.println(iAmInitialized.toString());//prints that object
        System.out.println(iAmNull.toString());//throws a NullPointerException
    }
}
Posted by: Guest on April-04-2021

Code answers related to "handle nullpointerexception in java"

Browse Popular Code Answers by Language