-1

I'm a java beginner and since I have been started learning i have been facing the error every time I try to run an program which takes input from the user not only with the loops. The error is:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at x.main
azro
  • 53,056
  • 7
  • 34
  • 70
  • 2
    Without seeing the corresponding part of the code, it is hard to say what exactly is wrong here - It seems you have an empty array but trying to read its first element – B001ᛦ Jul 13 '20 at 19:14

1 Answers1

0

You have declared the array of zero length (0-capacity). At the same time you are trying to access the first element of that array (in arrays the first element has the index 0).

This is why you are getting such exception. Because your array of zero-size does not have even first element.

Alexey R.
  • 8,057
  • 2
  • 11
  • 27