动手动脑11.11

请阅读并运行AboutException.java示例,

import javax.swing.*;

class AboutException {
   public static void main(String[] a) 
   {
      int i=1, j=0, k;
      k=i/j;


	try
	{
		
		k = i/j;    // Causes division-by-zero exception
		//throw new Exception("Hello.Exception!");
	}
	
	catch ( ArithmeticException e)
	{
		System.out.println("被0除.  "+ e.getMessage());
	}
	
	catch (Exception e)
	{
		if (e instanceof ArithmeticException)
			System.out.println("被0除");
		else
		{  
			System.out.println(e.getMessage());
			
		}
	}

	
	finally
     {
     		JOptionPane.showConfirmDialog(null,"OK");
     }
		
  }
}

  

猜你喜欢

转载自www.cnblogs.com/gkl20173667/p/9943978.html