class Example{
public static void main(String[] args)
{
System.out.println(args[0]);
}
}
编译时没出错 但运行时就会出现这个
Exception in thread "main"java.lang.ArrayIndexOutOfBoundsException: 1
at Example.main(Example.java:5)
Press any key to continue...
请各位看看这是怎么回事,程序应该没什么问题吧,是不是我的classpath设置有问题啊,还是其他原因,有还几个其他的程序运行时也出现得这样的情况,各位高手,请赐教啊,帮小妹一个忙。
參考答案:显示错误是下标越界.
你运行的时候,后面应该加个参数
java Example AAA 这个AAA就是参数.就代表args[0]