Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at javaapplication5.JavaApplication5.main(JavaApplica tion5.java:23)
The code at line 23 used an index past the end of the String. The index of 0 requires that the String have at least 1 character. If the String is empty it does not have a character at the first location: index of 0.
Check that the String has the needed number of characters before trying to access one.
Your using the array's .length field is the standard way to iterate through an array's contents.
To see what is in an array use the Arrays class's toString method:
System.out.println("an ID "+ java.util.Arrays.toString(theArrayName));
Note: The console printout only shows that 5 words were entered. Did you hit Enter an extra time?