class Student implements Cloneable
{
String a;
int b;
Student(String a,int b)
{
this.a=a;
this.b=b;
}
public Object clone()
{
Object o=null;
try
{
o=super.clone();
}
catch(CloneNotSupportedException e)
{
System.out.println(e.toString());
}
return o;
}
}
class Test
{
public static void main(String [] args)
{
Student a=new Student("nihao",2);
Student b=(Student)a.clone();
}
}
编译没错 ,执行抛出java.lang.NoClassDefFoundError错误 哪里错了?
{
String a;
int b;
Student(String a,int b)
{
this.a=a;
this.b=b;
}
public Object clone()
{
Object o=null;
try
{
o=super.clone();
}
catch(CloneNotSupportedException e)
{
System.out.println(e.toString());
}
return o;
}
}
class Test
{
public static void main(String [] args)
{
Student a=new Student("nihao",2);
Student b=(Student)a.clone();
}
}
编译没错 ,执行抛出java.lang.NoClassDefFoundError错误 哪里错了?
java -cp . Test
来执行,
-cp .
指定当前路径为CLASSPATH