class Test
{
public static void main(String[] args)
{
int num1,num2,sum;
num1 = Integer.parseInt(s[0]);
num2 = Integer.parseInt(s[1]);
sum = num1 + num2;
System.out.println(num1+"+"+num2+"="+sum);
}
}
/*
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Test.main(Test.java:7)
一直很郁闷,后来一看,哈 从屏幕上直接输入数字就可以了,如下:
C:\Users\lyme\Desktop>javac Test.java
C:\Users\lyme\Desktop>java Test 2 4
2+4=6.
有时很简单的问题,却搞得很复杂.
|