Duplicate :
|
|
Relates :
|
A DESCRIPTION OF THE REQUEST : Reopen 4995668 as a request for enhancement http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4995668 JUSTIFICATION : It is very difficult to understand the current specification of autoboxing/unboxing. Because narrowing primitive conversion after unboxing conversion and widening primitive conversion before boxing conversion doesn't work well. It needs an extra cast. Although int i1 = (int)2L; can be compile, int i2 = (int)Long.valueOf(2L); ^^^^^ can not be compiled. Now, int i3 = (int)(long)Long.valueOf(2L); ^^^^^^ can be compile. Although float f1 = 2; can be compile, Float f2 = 2; can not be compiled. Now, Float f3 = (float)2; ^^^^^^^ can be compile. P.S. Although long l1 = 2; can be compile, Long l2 = Integer.valueOf(2); can not be compiled. Now, Long l3 = (long)Integer.valueOf(2); ^^^^^^ can be compile. I want to write Long l2 = Integer.valueOf(2);