aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Stack Over flow error when Instantiating Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic
Author

Stack Over flow error when Instantiating

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
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

Joined: Dec 04, 2005
Posts: 81
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

Joined: Jun 21, 2006
Posts: 96
Hi

I am not getting any error.

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

Thanks
Stary Kapec
Ranch Hand

Joined: Dec 04, 2005
Posts: 81
Hi,

Try to instantiate the class. Add the main method.

wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
You can fix the problem by adding "static" modifier

[ August 16, 2006: Message edited by: wise owen ]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
 
Don't get me started about those stupid light bulbs.
 
subject: Stack Over flow error when Instantiating