GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes StackOverflowError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "StackOverflowError" Watch "StackOverflowError" New topic
Author

StackOverflowError

meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305


Exception in thread "main" java.lang.StackOverflowError
at Test.<init>(Test.java:3)
at Test.<init>(Test.java:3)
at Test.<init>(Test.java:3)
at Test.<init>(Test.java:3)
at Test.<init>(Test.java:3)
at Test.<init>(Test.java:3)
at Test.<init>(Test.java:3)
at Test.<init>(Test.java:3)

I don't understand reason.


My one regret in life is that I am not someone else.
- Woody Allen
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11356
    
  16

what happens when you do this:

Test obj=new Test();

you make a Test object. What does it hold? Two Test objects. Each of those has to hold two Test objects, each of which have to hold two Test objects...

and eventually you run out of stack space.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

Thanks
 
GeeCON Prague 2014
 
subject: StackOverflowError