日期:2014-05-20 浏览次数:20838 次
Stu s = new Stu();//new一个Stu对象
class Stu{
int id;
Stu f;
Stu() {
id = 0;
f = this; //想用 f 指向刚 new 的这个对象
}
}
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("hello\n");
Stu s = new Stu();
System.out.println(s.f.id);//用s.id会更直接些!
}
}
class Stu{
int id;
Stu f;
Stu() {
id = 3;
f = this; //想用 f 指向刚 new 的这个对象
}
}