-1

So I'm watching a tutorial to learn how to program in Java using Eclipse. So I got a few episodes in and I had to clear out all out the errors. I looked around and found no more errors so I tried to run the program and I got errors in that were only displayed in the console, and was being displayed next to the lines it was referencing. I have completely no idea how to solve these errors I haven't seen anything like them before. Also my program is fairly simple it is just the code to display and window and then have pixels of a random colour fill that window. I really would appreciate any help I can get, because I have no clue how to fix this error.

Thanks, Nova

Tutorial

Error:

`Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar` 

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 65536 
at cpm.mime.GameP1.graphics.Screen.<init>(Screen.java:14) 
at com.mime.GameP1.Display.<init>(Display.java:29) 
at com.mime.GameP1.Display.main(Display.java:92)`
BillRobertson42
  • 12,602
  • 4
  • 40
  • 57
nova nanite
  • 135
  • 1
  • 6
  • 5
    Please post your Screen and Display source code. – Lasse Meyer Aug 31 '15 at 13:17
  • You should always post [a minimal, complete code sample](http://stackoverflow.com/help/mcve) in your question. Although you should be able to figure out an `ArrayIndexOutOfBoundsException` by just thinking what all those words mean and checking the line it's occurring on. – Bernhard Barker Aug 31 '15 at 14:39
  • This may be helpful - [What is a stack trace, and how can I use it to debug my application errors?](http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors) – Bernhard Barker Aug 31 '15 at 14:46

1 Answers1

0

This line:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 65536 

Tells you that you're attempting to access an element in an array that does not exist. The number 65536 is the number you've supplied, but the array is not that large. For example, if you had an array with 10 elements in it (which would be indices [0,9]), and you tried to access the 11th element (index 10), it would generate the same error, but tell you that index 10 does not exist.

This line:

at cpm.mime.GameP1.graphics.Screen.<init>(Screen.java:14) 

Tells you that the error occurs at line 14 in Screen.java.

And these lines:

at com.mime.GameP1.Display.<init>(Display.java:29) 
at com.mime.GameP1.Display.main(Display.java:92)

Tell you the calls that led to where the error occurs. e.g. Display's constructor (line 29), which was called was called by main in Dislplay.java line 92. Stack traces are read from the top down.

BillRobertson42
  • 12,602
  • 4
  • 40
  • 57