dcsimg
No nullpoiter
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, August 1, 2002 12:34 PM

How can i handle with nonullpoiter, thank you very much

Re: No nullpoiter

Posted By:   Lasse_Koskela  
Posted On:   Thursday, August 1, 2002 01:55 PM

I assume you mean "NullPointerException"?


Here's an example:


public void someMethod()
{
try
{
// some code, which may throw a NullPointerException
System.out.println("1");
throw new NullPointerException("just testing");
System.out.println("2");
}
catch (NullPointerException npe)
{
System.out.println("Encountered a NullPointerException: " + npe.getMessage());
}
System.out.println("3");
}


This code prints:


1
Encountered a NullPointerException: just testing
3


If you wouldn't catch the exception with a try-catch block, the execution would stop abruptly after printing "1".

About | Sitemap | Contact