package Day11;
import java.util.Scanner;
public class Try {
public static void main(String[] args) {
// TODO Auto-generated method stub
Try t = new Try();
try {
int num = t.div(4,0);
System.out.println(num);
} catch (Exception e) {
System.out.println("异常啦!");
}
}
int div(int a,int b)throws Exception{
return a/b;// throw new Exception
}
}
class If{
Scanner s = new Scanner(System.in);
int num = s.nextInt();
void function(){
if(!(num==0)){
int num = div(4,0);
System.out.println(num);
}
else{
System.out.println("异常啦");
}
System.out.println("over");
}
int div(int a, int b){
return a/b;
}
} |
|