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?
All code in my posts, unless a source is explicitly mentioned, is my own.
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 "String", which is now easily explained through the efforts compiler makes to find the most specialized code.
All code in my posts, unless a source is explicitly mentioned, is my own.
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 "String", 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!![]()
Cristian Senchiu wrote:
Thanks Ruben.
The String case is that one case that throws already at lineX, where no other type of object throws. Remember? Was in our discussion at the very beginning.
That's explainable now because 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).
All code in my posts, unless a source is explicitly mentioned, is my own.
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.
All code in my posts, unless a source is explicitly mentioned, is my own.
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.![]()
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |