Tuesday, 1 October 2013

Method out of space?

Method out of space?

Today I got the following error message for the first time ever...
java.lang.Error: Unresolved compilation problem:
The code of method init() is exceeding the 65535 bytes limit
at generator.Main.init(Main.java:36)
at sun.applet.AppletPanel.run(AppletPanel.java:425)
at java.lang.Thread.run(Thread.java:680)
The error is being caused because I am creating an array list with around
10,000 ints in my init() method. The solution to this problem is not very
complicated, I made 3 methods that each had 3,300 ints in them and called
them all from my init().
But I have a couple questions purely out of curiosity.
Why do methods have a limit on space?
Why is it limited to 65535 bytes? (2^something-1?)
Is there any way to give a method more space or will they all be limited
the same amount?
How much information exactly is 65535 bytes?

No comments:

Post a Comment