コード:
package exceptiona;
import java.io.IOException
public class ExceptionTest {
@SuppressWarnings("empty-statement")
public static void main (String[] args)
{
// call exceptionA
try{
throw new ExceptionA();
} catch (Exception e){
e.printStackTrace(};
System.out.println ("threw Exception A")
// call exceptionB
try{
throw new ExceptionB();
} catch (Exception e) {
e.printStackTrace(};
System.out.println ("threw Exception B")
// throw a NullPointerException
try{
throw new NullPointerException
} catch (NullPointerException){
nu
}
// throw IOException
try{
throw new IOException();
} catch (IOException io){
io.printStackTrace();
}
}
}