You are getting the ArrayIndexOutOfBoundsException: 0
because you are trying to access to the first element of the array args
, but this doesn't have any elements.
What can you do?
- You should pass command-line arguments to the program when you launch it.
You can check if the length of
args
is greater than0
before you access to its elements:if (args.length > 0) // ...