我是java新手我不明白为什么异常类引用变量打印消息和普通类的引用变量打印eclassname@jsjka为什么?
public class Exception11 {
int x,y;
public static void main(String[] args) {
try{
int total;
Exception11 e=new Exception11();
e.x=10;
e.y=0;
total=10/0;
System.out.println("Value of refernce variable: "+e);
System.out.println(total);
} catch (ArithmeticException h) {
System.out.println("number can not divide by the 0 Please try again");
int total;
Exception11 e=new Exception11();
System.out.println("Value of refernce variable: "+e);
System.out.println("Value of refernce variable: "+h);
}
}
}
回答 - - - - - - - - - - - - - - -
number can not divide by the 0 Please try again
Value of refernce variable: Exception11@4f1d0d
Value of refernce variable: java.lang.ArithmeticException: / by zero