Bookmark Topic Watch Topic
  • New Topic

Stack Over flow error when Instantiating

 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi all
can any one tell me whats the problem in the below code

i am getting stack overflow erro when instantiating Temp1
new Temp1() gives me stackoverflow error

 
Stary Kapec
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,



Every time you create Temp1 instance you create another two Temp1 instances, and every time one of these two instances is created another two Temp1 instances are created and so on, and so on...
The circular association in your class causes the problem.
[ August 15, 2006: Message edited by: Jasiek Motyka ]
 
Sujittt Tripathyrr
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi

I am not getting any error.

can you please tell me where are you getting the error.

Thanks
 
Stary Kapec
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

Try to instantiate the class. Add the main method.

 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Report post to moderator
You can fix the problem by adding "static" modifier

[ August 16, 2006: Message edited by: wise owen ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is a duplicate, with the same answer. Parameswaran, please don't post the same question in more than one forum here; it just wastes people's time when they respond to it without knowing it's already been answered elsewhere.

Followups go here.
 
    Bookmark Topic Watch Topic
  • New Topic