What is this version of the code doing for you?
For me, it didn't compile right away. The line Ball ball = new Ball(); is trying to call a method that doesn't exist (there is no empty constructor for the Ball class).
When I changed that line so it was calling the real constructor, I get a stack overflow error (Exception in thread "AWT-EventQueue-1" java.lang.StackOverflowError) because when I call the constructor once, it recursively calls the constructor again and again until I'm out of available stack memory.
So, I wanted to see what kind of things your'e experiencing before we overhaul this and try to adjust the mindset of this approach.
edit: restating the reason for StackOverflowError
Show differencesHistory of post edits
#2j-locke
Posted 11 August 2012 - 12:23 PM
What is this version of the code doing for you?
For me, it didn't compile right away. The line Ball ball = new Ball(); is trying to call a method that doesn't exist (there is no empty constructor for the Ball class).
When I changed that line so it was calling the real constructor, I get a stack overflow error (Exception in thread "AWT-EventQueue-1" java.lang.StackOverflowError) because I'm now trying to create an array and 4 ball objects every time the applet tries to paint (which is well above 100 times per second).
So, I wanted to see what kind of things your'e experiencing before we overhaul this and try to adjust the mindset of this approach.
For me, it didn't compile right away. The line Ball ball = new Ball(); is trying to call a method that doesn't exist (there is no empty constructor for the Ball class).
When I changed that line so it was calling the real constructor, I get a stack overflow error (Exception in thread "AWT-EventQueue-1" java.lang.StackOverflowError) because I'm now trying to create an array and 4 ball objects every time the applet tries to paint (which is well above 100 times per second).
So, I wanted to see what kind of things your'e experiencing before we overhaul this and try to adjust the mindset of this approach.
#1j-locke
Posted 11 August 2012 - 12:20 PM
What is this version of the code doing for you?
For me, it didn't compile right away. The line Ball ball = new Ball(); is trying to call a method that doesn't exist (there is no empty constructor for the Ball class).
When I changed that line so it was calling the real constructor, I get a stack overflow error (Exception in thread "AWT-EventQueue-1" java.lang.StackOverflowError) because I'm now trying to create an array and 4 ball objects every time the applet tries to paint (which is 100+ times per second).
So, I wanted to see what kind of things your'e experiencing before we overhaul this and try to adjust the mindset of this approach.
For me, it didn't compile right away. The line Ball ball = new Ball(); is trying to call a method that doesn't exist (there is no empty constructor for the Ball class).
When I changed that line so it was calling the real constructor, I get a stack overflow error (Exception in thread "AWT-EventQueue-1" java.lang.StackOverflowError) because I'm now trying to create an array and 4 ball objects every time the applet tries to paint (which is 100+ times per second).
So, I wanted to see what kind of things your'e experiencing before we overhaul this and try to adjust the mindset of this approach.