My program looks like this:
public class Main {
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = a + b;
System.out.print("Sum is" + a);
}
}
I'm trying to give as command line arguments two integer numbers, then calculate the sum of the two. I read that this is the way for Java to receive these parameters, but I'm getting an error:
Exception in main thread java.lang.ArrayIndexOutofBoundsException
Why is that? Why am I out of bounds for my array args?