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或者空行之类的?
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或者空行之类的?
资料:http://hi.baidu.com/herotang/blog/item/3e18d63f6483a9c57d1e71cb.html
你new Test();是创建了一个对象,输出的就是你创建对象得地址。