when I type in 2 command line arguments I get arrayindexoutofBoundsexception :2 I just do not understand why, when i type in 3 command line arguments it works its just 2 command line arguments which give me an array error
public static void main(String[] args) {
if(args.length == 1){
System.out.println(args[0]);
}
if(args.length == 0) {
System.out.println("number of arguments invalid");
}
else{
try{
double a = Double.parseDouble(args[0]);
double b = Double.parseDouble(args[1]);
double c = Double.parseDouble(args[2]);
if(args.length == 3){
System.out.println(a*b*c);
}
else if(args.length == 2){
System.out.println(a*b);
}
else if (args.length > 3){
System.out.println("number of arguments invalid");
}
}catch(NumberFormatException e){
System.out.println("invalid operation");
}
}
}
}