一段小程序:
class ArrayTest
{
public static void main(String[] args)
{
int[] num1=new int[]{1,2,3};
int[] num2=new int[3];
System.arraycopy(num1,0,num2,0,num1.length);
for(int i=0;i<num2.length;i++)
{
System.out.println(num2[i]);
}
}
}
如果在JCreator中不编译,直接运行,就会出现:
Exception in thread "main" java.lang.NoClassDefFoundError: ArrayTest
Press any key to continue...
经过编译后,将生成ArrayTestCLASS文件,再运行,就会出现正确的结果:
1
2
3
press any key to continue...