Jump to content
  • Advertisement
Sign in to follow this  
LinkOfTime

[java] Hi, I have a newbie question...

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Lately I have moved to Java programming and am still studing the language... Now, I made an example program (more or less like in a book I have got) and have a question about it... When I create a dynamic reference to an object in the main method ("meal X = new meal();"), which is in the public class meal, I don't get any compilation errors, but, when running the program, it says: "Exception in thread "main" java.lang.StackOverflowError". When I create a dynamic array reference to the same object ("meal[] X = new meal[0];"), in the same public class, I don't get that error... Can someone please tell me what the problem is... Thanks in advance for the help :)

Share this post


Link to post
Share on other sites
Advertisement
Something you're calling from the constructor is causing recursion beyond what your system can handle. Basically, you've done something like this:

class MyClass
{
public MyClass( int do ) { process(do); }
private void process(int do) { process(do); } // Throw stack-overflow.
}

I reccomend checking your code or pass through a java debugger.

Share this post


Link to post
Share on other sites
Yeah, you were right...
I rechecked the code and the was a recursion in a class called from the constructor...
Thanks for the help :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!