I'm really new to coding and is stuck on some java code. I've researched this problem, but can't seem to find the answer, or understand what's wrong with my code.
I'm making a program that takes three integer command-line arguments and prints equal if all three are equal, and not equal otherwise.
My code looks like this
public class ThreeInteger {
public static void main (String[] args){
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = Integer.parseInt(args[2]);
if ((a==b) && (b==c) && (a==c)) {
System.out.println("equal");
}
else {
System.out.println("not equal");
}
}
}
When i try to run i get get this: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at ThreeInteger.main(ThreeInteger.java:5)
How do I get rid of this?