I had a check for it there is no spelling mistake in the name of the class and i am trying to run the following code
Code:
class UsingExceptions
throwException();
code
public class UsingExceptions
{
public static void main( String args[] )
{
try
{
throwException();
}
catch ( Exception exception )
{
System.err.println( "Exception handled in main" );
}
}
public static void doesNotThrowException()
{
try
{
System.out.println( "Method does not ThrowException" );
}
catch ( Exception exception )
{
System.err.println( exception );
}
finally
{
System.err.println( "finally executed in doesNotthrowException" );
}
System.out.println( "End of method doesNotThrowException" );
}
public static void throwExceptionB() throws Exception
{
try
{
System.out.println( "Method throwExceptionB" );
throw new Exception();
}
catch ( Exception exception )
{
System.err.println(
"Exception handled in method throwException" );
throw exception;
}
finally
{
System.err.println( "finally executed in throwException" );
}
}
{
try
{
System.out.println( "Method throwException" );
throw new Exception();
}
catch ( Exception exception )
{
System.err.println(
"Exception handled in method throwException" );
}
finally
{
System.err.println( "finally executed in throwException" );
}
}
public static void throwExceptionNullPointer() throws Exception
{
try
{
System.out.println( "Method throwException" );
throw new Exception();
}
catch ( Exception exception )
{
System.err.println(
"Exception handled in method throwException" );
throw exception;
}
finally
{
System.err.println( "finally executed in throwException" );
}
}
public static void throwExceptionIO() throws Exception
{
try
{
System.out.println( "Method throwException" );
throw new Exception();
}
catch ( Exception exception )
{
System.err.println(
"Exception handled in method throwException" );
throw exception;
}
finally
{
System.err.println( "finally executed in throwException" );
}
}
}
Bookmarks