As you can probably understand from the question itself, I\'m new to Java. I was given an exercise to write a Java program which receives a character, prints it and the next
The default run configuration in Eclipse runs a Java program without any arguments, hence the ArrayIndexOutOfBoundsException
. Your code is trying to get first element of the args
array when there aren't any!
You can edit the run configuration to provide the arguments to run your program with. Then it should not throw this exception.
However, a good practice is to check the size of array before accessing it's elements, more so when the array is coming as an argument from outside of your code.