This example get details of Exception with toString(), getMessage() and printStackTrace().
package javadisplayexception;
/**
* @web http://java-buddy.blogspot.com/
*/
public class JavaDisplayException {
public static void main(String[] args) {
try{
int i = 10/0;
}catch (Exception ex){
System.out.println("- ex.toString() -");
System.out.println(ex.toString());
System.out.println();
System.out.println("- ex.getMessage() -");
System.out.println(ex.getMessage());
System.out.println();
System.out.println("- ex.printStackTrace() -");
ex.printStackTrace();
}
}
}
No comments:
Post a Comment