Mahalakshmi Chandru wrote:Cristian,
Thanks for clarifying the doubt. Its clear now. After i completed reading the wrapper classes topic and the autoboxing , its pretty much clear now. Im trying to understand the underlying behaviour of the classes by looking through the jdk installation.
Ruben Soto wrote:You are absolutely right, Cristian. I missed the part that says "If only one of the operands is a String." So things make absolute sense now, thanks.
I hope you enjoyed your movie. I also saw a movie. It starred javac and had a lot of exciting exceptions. In the end everything compiled right.![]()
Ruben Soto wrote:I think the main thing is that I don't see how there is a specific concatenation for String + String. I looked in the JLS (15.8.1) and I don't see a mention of a special case when both operands are Strings vs (for example) a String and a StringBuffer. Where did you find in the JLS this information?
... there's the specific concatenation for case String+String (so for compiler the String+<reference> is not the best choice anymore as it would be in case of any object, including StringBuffer for example).
If only one operand expression is of type String, then string conversion is performed on the other operand to produce a string at run time.
Ruben Soto wrote:
Cristian Senchiu wrote:Yes Ruben and Ankit, it was!
![]()
P.S.: I just reread my post and saw that I didn't write about the special case &amp;quot;String&amp;quot;, which is now easily explained through the efforts compiler makes to find the most specialized code.
Cristian, I am afraid I don't follow. How is String explained, when String and StringBuffer (for example) behave differently in the first case?
Good work, by the way!![]()
Mahalakshmi Chandru wrote:Cristian,
could you please elaborate what happens in the below 2 code snippets:Its kinda confusing
Karl Krasnowsky wrote:
1) code on line 21 has a call Suits.SPADES.points and that can't work because the points member is private. Compile error #1.
...
Mahalakshmi Chandru wrote:Hi,
Please clarify whether both I and Is are same:
nagaraju uppala wrote:Thanks cristian
![]()
now my doubt is cleared. you mean at runtime also the generics will replaced with object type.am i right?
Ankit Garg wrote:
This is the same code that the compiler generates for the println statement. But there is no exception at the println statement. May be this is because the println statement (or infact any string concatenation like at line no 14) is modified to StringBuilder code by the compiler after the generics code is erased...
Ruben Soto wrote:Good one, Ankit! Excellent test, which clears up some doubts.
Eric Pascarello wrote:for a second change the 5000 to 1000
sandeep kethe wrote:... which has to be reloaded for every five seconds