我在我的 64 位 Linux 系统上用 Java 编写了这段代码:
class WrapperClass1
{
public static void main(String s [])
{
int noinput=s.length;
System.out.println("Number of values entered is :- " + noinput);
System.out.println( s[0] + "," + s[1] );
int x = Integer.parseInt(s[0]);
int y = Integer.parseInt(s[1]);
int z = x + y;
System.out.println(" Sum = " + z);
}
};
现在,当我尝试编译它时,它会成功编译,但是当我执行程序时,它会显示一个名为的异常:
Number of values entered is :- 0
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at WrapperClass1.main(WrapperClass1.java:7)