java.lang.ArrayIndexOutOfBoundsException: 0 - Array larger than Index?

The array doesn't contain any elements--it is an empty array. So when you ask for the first element in the array (the element contained at index 0) the array says "I don't have an element at index 0". It 'says' this by throwing an exception. In your case, the exception is java.lang.ArrayIndexOutOfBoundsException: 0

This means that the index you requested is outside the bounds of the array. In other words, the array has a length (it's bounds). When it's length is 0 (it's empty) and you ask for the 1st element, the array tells you the item you requested is unavailable because the array isn't even 1-element long.


It means the array is smaller than the index. In that case it means the array is empty.

You should pass a command-line argument in order to have a value there. And if it is required, you'd better add some validation, like

if (args.length == 0) {
    throw new IllegalArgumentException("year is required");
}

It means that it is smaller than the index. In other words, there were no command line arguments, and you are assuming that there was at least one.