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;
}
运行结果如下:
java.lang.NoClassDefFoundError: PassReference
Exception in thread "main" 

解决方案 »

  1.   

    你编译没?
    javac PassReference.java
    java PassReference
      

  2.   

    我这里可以运行的,可能你没有编译,编译好了运行PassReference.class文件。
      

  3.   

    这个异常告诉你 没有找到要运行的类你应当先编译  javac PassReference.java 
    在运行  java Passreference.java
      

  4.   

    呀 打错 运行时是 java Passreference
    没.java 
    呵呵
      

  5.   

    谢谢大家.但是这个确实在eclipse里运行不了.有兴趣的可以去试试