當我運行下面給出的代碼時,出現以下消息。這意味着什麼?在這種情況下如何克服它?Java程序中的異常
異常線程 「main」 java.lang.ArrayIndexOutOfBoundsException:0 在ifDemo.main(ifDemo.java:5)
public class ifDemo {
public static void main (String [] args)
{
int x= Integer.parseInt(args[0]);
double half=0.0;
if (x!=0)
{
half=x/2.0;
System.out.println(x+ "/2 = "+half);
}
if (x==0)
{
System.out.println("The value of x is "+x);
}
int y=x*5;
char grade='F';
if(y>=85)
{
grade='A';
}
if (y>=70 && y<85)
grade='C';
System.out.println("y= "+y+ "and grade equal to "+grade);
}
}
我正在通過Eclipse IDE運行它。 – josh 2013-04-21 07:03:20
看看這個[鏈接](http://stackoverflow.com/questions/7574543/how-to-pass-console-arguments-to-application-in-eclipse)。這對你有幫助。 – Maximin 2013-04-21 07:10:55