日期:2014-05-20 浏览次数:21006 次
public class PassReference
{
public static void main(String[] ar)
{
Test c = new Test();
System.out.println("在调用方法inceptReference()之前,c.a的值为:" + c.a);
inceptReference(c);
System.out.println("在调用方法inceptReference()之后,c.a的值为:" + c.a);
}
static void inceptReference(Test t)
{
System.out.println("The first value of t.a is:" + t.a);
t.a++;
System.out.println("The second value of t.a is:" + t.a);
}
}
class Test
{
public int a = 0;
}