public class Test {
static int total = 10; public static void main(String args[]) {
new Test();
} public Test() {
System.out.println("In test");
System.out.println(this);
int temp = this.total;
if (temp > 5) {
System.out.println(temp);
}
}
}In test
Test@de6ced
10
输出这,第二行是什么,是this的地址吗?@是干嘛的?既然没有值为什么不输出NULL或者空行之类的?

解决方案 »

  1.   

    自动调用object类的toString()方法返回一个字符串,该字符串由类名、@ 和此对象哈希代码的无符号十六进制表示组成。
    资料:http://hi.baidu.com/herotang/blog/item/3e18d63f6483a9c57d1e71cb.html
      

  2.   

    差不多是个地址吧,确切点是this的toString方法输出的,System.out.println();方法,如果你传入一个对象的话,会自动调用此对象的toString方法,而你的Test类由于没有重写Object的toString,会调用Object类的toString,楼主可以看一下jdk的源代码,是输出类名(带包名)@哈希吗,组成 的字符串,
      

  3.   

    第二行输出得就是一个地址,this代表是当前对象得引用
    你new Test();是创建了一个对象,输出的就是你创建对象得地址。
      

  4.   

    输出这,第二行是this对应对象的 类名@hashcode