SCJP 5 <br /> SCWCD 5 <br /> SCBCD <br />
Figuring out what's next...
Leandro Melo
SCJP 1.4, SCWCD 1.4
Originally posted by Konda Golamaru:
Hi ,
I am not clear on why c3 is not eligible for garbage collection though c3 receives null reference. Is not it that c3=null hence eligible for garbage collection.
Pls. explain.
Thanks,
Konda Golamaru.
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
Regards,<br />Sourin.
ॐ सर्वे जना: सुखिनो भवन्तु , तथास्तु |
'May the whole world be happy, so be it'
SCJP1.5, SCWCD1.5
Regards,<br />Sourin.
ॐ सर्वे जना: सुखिनो भवन्तु , तथास्तु |
'May the whole world be happy, so be it'
SCJP1.5, SCWCD1.5
So, in this case, since the value of the "Short story" is 5, (ie, <127), there will be only one object created for short irrespective of the number of objects created for the CardBorad class.
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Originally posted by Mak:
I have seen this same question in Kathy and Bert(SCJP 1.5), Chapter 3, page number 267
where answer is given 2 (one is c1 and second is that Short Object), has anyone reported it ? So as per Sourin's explanation Kathy's answer is wrong right ?
[ June 12, 2007: Message edited by: Mak ][/QB]
Regards,<br />Sourin.
Originally posted by Raghavan Muthu:
I think the line
is of JDK 1.5 as with autoboxing. aint I? As with JDK 1.4 its not possible to have a direct assignment.
The concept what you told also holds good with JDK 1.5 only or also with JDK 1.4 Sourin? Please clarify!
Regards,<br />Sourin.
So, in this case, since the value of the "Short story" is 5, (ie, <127), there will be only one object created for short irrespective of the number of objects created for the CardBorad class.
Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
Originally posted by krishna bulusu:
Consider the following programme:
The out put of the above programme must be 10-10 according to the above quote.
But the actuall Out put is 5-10.
could anyone explain this?
Regards,<br />Sourin.
Here, when you are re-assigning the variable, a new Short object is being created, assigned a value 10, & then its reference is stored.
Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
Regards,<br />Sourin.
Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
obj1 has (1) -> byteWrapper1 = -128, byteWrapper2 = 125, bytePrimitive = 127, stringVar = WrapperImmutableTest
obj2 has (1) -> byteWrapper1 = -128, byteWrapper2 = 125, bytePrimitive = 127, stringVar = WrapperImmutableTest
----- Effects after changing obj1's value -----
obj1 has (2) -> byteWrapper1 = 12, byteWrapper2 = 120, bytePrimitive = 122, stringVar = WrapperImmutableTest - 2
obj2 has (2) -> byteWrapper1 = -128, byteWrapper2 = 125, bytePrimitive = 127, stringVar = WrapperImmutableTest
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Originally posted by harinath chakrapani:
friends its clear to you that c1(object) is null so, the object that c1 points is eligible for GC. go(c2), here the reference is only passed and not the object so the reference c2 now points to null.
Originally posted by Raghavan Muthu:
Are the line 1 and 2 not contradicting? I dont see any difference between the pairs {I1,I2} and {I3,I4}. But how come a check on both "equals" and "not equals" will be true?
Was it a typo or do i miss something here!? :roll:
Leandro Melo
SCJP 1.4, SCWCD 1.4
Originally posted by harinath chakrapani:
friends its clear to you that c1(object) is null so, the object that c1 points is eligible for GC. go(c2), here the reference is only passed and not the object so the reference c2 now points to null. object which was previously assigned to c2 is not destroyed and is not eligible for GC.
Raghavan, this is not a contradiction. It's related to what Souring said about the value being greater than 127 (which was a nice observation by the way).
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Originally posted by Raghavan Muthu:
Hi Leandro,
Thanks for the inputs.
I think you have not seen the later part given by harinath. What he told is fine. Aint I?
Originally posted by Raghavan Muthu:
Thank you Leandro and Souring!! Thats a good point obviously. I missed to notice the difference in the values being "<127" and ">127"!!![]()
But I dont get that immutability in JDK 1.4 version. See my previous reply for the same with the sample program. Any inputs on that? :roll:
Leandro Melo
SCJP 1.4, SCWCD 1.4
Yes I did see that. I didn't quote it intentionally, because in my opinion the paragraph is self-contradictory
That's because such immutability doesn't happen in Java 1.4. In the case of Integers, Bytes, etc, it only makes sense with boxing/unboxing, which is not available in Java 1.4.
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |