| Author |
widening and boxing...
|
sweety singh
Ranch Hand
Joined: Dec 15, 2007
Posts: 49
|
|
-------------------------------------------------------------------------------- code class WidenAndBox { static void go(Long x) { System.out.println("Long"); } public static void main(String [] args) { byte b = 5; go(b); // must widen then box - illegal } } // why cant i widen first and then box... byte can be widened to long and then long can be boxed to Long... then why is it illegal...
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 13395
|
|
// why cant i widen first and then box... byte can be widened to long and then long can be boxed to Long... then why is it illegal...
Simply, because it doesn't. The specification is very specific on what it does. If you want it to widen and then box, you have to explicitedly widen it first. Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: widening and boxing...
|
|
|