It may sound stupid question, but I must ask
In the code below the object reference d2 is cerated using null d1. so what this object is like? is it also null?
also with line Dog d1 = null, do we get an object on the heap?
Thanks in advance.
Anu
SCJP5.0, SCJA
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32673
4
posted
0
Have you tried it? Will that code actually compile?
jittu goud
Ranch Hand
Joined: Mar 30, 2007
Posts: 46
posted
0
you are using the non default Dog Constructor ..where is the implementaion of it ?
Why do you think it would be null? What, precisely, is happening when you execute the Dog(Dog d) constructor? Is is still instantiating a Dog?
jittu goud
Ranch Hand
Joined: Mar 30, 2007
Posts: 46
posted
0
David Newton wrote:@jittu goud: One way folks try to help beginners is to get them to think things through for themselves rather than just handing the answer to them!
oops my bad ....on the other side...iam a beginner myself..... :shock:
jittu goud
Ranch Hand
Joined: Mar 30, 2007
Posts: 46
posted
0
anu Its not null...
Dog d2 = new Dog(d1) ...
i think the "new Dog(d1)" will create a new object with null value
...but d2 will store the object reference ..rather than the actual object
in this case you should get the value of d2 as Dog@3e25a5
but still the d2.d will be null
jittu goud
Ranch Hand
Joined: Mar 30, 2007
Posts: 46
posted
0
i made a few changes....to your code
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.