File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Core Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Core Java" Watch "Core Java" New topic

Core Java

sagar sinha sagar

Joined: Aug 13, 2009
Posts: 1

Please post output with reason...
Matthew Brown

Joined: Apr 06, 2010
Posts: 4543

Hi Sagar. Welcome to The Ranch!

It'll be a more effective learning experience if you try it yourself first. What do you think it will output? Or, try compiling and running it yourself. If you don't understand why it does what it does, come back to us and we can help you.
shivang sarawagi
Ranch Hand

Joined: Jun 19, 2008
Posts: 153
is it legitimate to initialize a same object twice in a program within a same class ?? besides the object is calling itself it will be a stack overflow error.

I am too not sure about this. I changed the name of the objects, put them as three different objects then also there is a stack overflow error. Seniors please reply.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46375
You can't initialise the same object twice. You can initialise numerous instances of the same class, but they are different objects.

Write down some diagrams like those in this post, only you label the boxes t and t1 and t.t and t1.t etc etc. Then you can predict whether you will overflow your stack or not. As the chap who posted that older post said, pencil and paper and eraser. That's what you need to use
I agree. Here's the link:
subject: Core Java
jQuery in Action, 3rd edition