package Example1;
public class ExceptionExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
dividebyzero(2);
}
public static void dividebyzero(int a){
try{
a=a/0;
}
catch(Exception e){
System.out.println(e.getMessage());
System.out.println(e.toString());
e.printStackTrace();
}
}
}
output:/ by zero
java.lang.ArithmeticException: / by zero
java.lang.ArithmeticException: / by zero
at Example1.ExceptionExample.dividebyzero(ExceptionExample.java:11)
at Example1.ExceptionExample.main(ExceptionExample.java:7)
>>>Exceptions
------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment