Misjudgment return data

/ * Is not zero is determined, and j is zero is determined, an error is returned type 
Package
Test; import java.util.Scanner; import javax.swing.JOptionPane; public class Secetion { public static void main( String args[] ) { int i=100; int j=0; int c; Scanner sc=new Scanner(System.in); System.out.println ( "Please enter a number" ); j=sc.nextInt(); c=i/j; try { c = 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 ( "divide by zero" ); the else { System.out.println(e.getMessage()); } }

 

Guess you like

Origin www.cnblogs.com/sunhongbin/p/11755384.html