I've started learning java and I have a problem executing this,
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("Nothing found.");
}
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 = "+grade);
}
}
It compiles fine (I use
Jcreator) but when I execute it I get this message :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at IfDemo.main(IfDemo.java:7)
Thanks.