SCJP 6.0 96%
(Connecting the Dots ....)
Sahil Kapoor wrote:
1) It would unbox switch expression ie new Integer(4) and compares it with int w.
2) It would Box w and then compares with the switch expression.
When the switch statement is executed, first the Expression is evaluated. If the Expression evaluates to null, a NullPointerException is thrown and the entire switch statement completes abruptly for that reason. Otherwise, if the result is of a reference type, it is subject to unboxing conversion (ยง5.1.8). If evaluation of the Expression ....
SCJP 6.0 96%
(Connecting the Dots ....)
http://plainoldjavaobject.blogspot.in
SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
SCJP 6.0 96%
(Connecting the Dots ....)
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
as Integer i = 's'; won't compile
SCJP 6.0 96%
(Connecting the Dots ....)
http://plainoldjavaobject.blogspot.in
http://plainoldjavaobject.blogspot.in
M.Sc. in CS, OCPJP6 93%
Lalit Mehra wrote:
i have never worked on Eclipse. so can't clarify much on this.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:When you use == operator, if one of the operands is a primitive and the other is a wrapper class, the wrapper is unboxed. So in your case i is unboxed to int, then a is promoted to int and then the conversion is done...
http://plainoldjavaobject.blogspot.in
Lalit Mehra wrote:in case of the switch statement ... since the actual expression is evaluated only before being converted or unboxed or promotion ... this happens
Pradeep- Kumar wrote:from the logical thinking, I think switch as multiple if else, may be implementation wise there is difference the way if and switch statement converted into byte code.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Don't get me started about those stupid light bulbs. |