What does this JAVA exception mean?

by chatab
2 replies
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at Screen.draw(Screen.java:32)
at Menu.main(Menu.java:105)
I have no idea what it means.
#exception #java
  • Profile picture of the author David McKee
    It means that the array used in your program was accessed at a location it does not have, for example, if the array was defined as being length 10, and you accessed the array at it's 11th location, then you would get that error because it does not have an 11th location:

    String[] myArray = {"first", "second", "third"};
    System.out.println(myArray[3]);

    This would give you an error because the array is indexed starting at position '0'.

    myArray[0] = "first";
    myArray[1] = "second";
    myArray[2] = "third";

    I hope that helps.

    -DTM
    Signature
    Are you an affiliate marketer? My site has tons of free stuff and 14,000 pages of Clickbank research. www.affiliatesledgehammer.com
    Buy a Freedom Bulb! Don't let the government tell you what kind of light bulb you can use!
    {{ DiscussionBoard.errors[1653009].message }}
  • Profile picture of the author chatab
    oooh woow thanks for sharing .... let me check
    {{ DiscussionBoard.errors[1653018].message }}

Trending Topics