this is my first try at java and I'm having a little problem running it:
Here's the code:
public class Assignment1 {
public static void main(String args[]) {
int c = Integer.parseInt(args[1]);
if (c > args[0].length()) {
System.out.println("the index" + args[1] + "is out of range !");
} else {
System.out.println("The character is" + args[0].charAt(c - 1) + " !");
}
}
}
I get an error compiling it (Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at Assignment1.main(Assignment1.java:3) But thought it was just because I didn't input anything, and when trying to execute it in cmd "c:\ blah blah...\ java Assignment1.java 1234 5" and got the error mentioned before...
Any idea about what's wrong with the code? my settings? me? thanks.