public class Test
{
int i = 0;
public int getValue()
{
return this.i;
} public void test()
{
int t = this.getValue();
}public static void main(String[] args)
{
new Test().test().getValue();
}
}
{
int i = 0;
public int getValue()
{
return this.i;
} public void test()
{
int t = this.getValue();
}public static void main(String[] args)
{
new Test().test().getValue();
}
}
public class Test
{
int i = 0;
public int getValue()
{
System.out.println("in getValue") ;
return this.i;
} public void test()
{
int t = this.getValue();
System.out.println("test called,i="+i);
}public static void main(String[] args)
{
new Test().test();
//Test tt= new Test();
//System.out.println("ok,started");
//tt.test();
}
}运行结果。
in getValue
test called,i=0没错吧
{
int t = this.getValue();
}
t是临时变量,没用
为什么要加上
System.out.println("会不会来")
不理解??
为什么要加上
System.out.println("会不会来")
不理解??
----------------
看看有没有执行到该地方,执行到就在控制台输出相应的字符串
print只不过是让你确认一下如果是make的时候,那个debug选项有没有选所有啊? line, field, variable,并且使用step into, 或者直接在int t = this.getValue();加上break point
够你happy了吧