Print exception stack trace
public class Main { public static void main(String[] args) { try { float f = 1/0; } catch (Exception e) { e.printStackTrace(System.out); } } }
java.lang.ArithmeticException: / by zero at Main.main(Main.java:4)
Print exception short description
public class Main2 { public static void main(String[] args) { try { float f = 1/0; } catch (Exception e) { System.out.println(e); // or System.out.println(e.toString()); } } }
java.lang.ArithmeticException: / by zero