Hi all, I have question.Just check the following code public class b1{ public static void main(String arg[]){ final short s=10; byte b=s; //will not compile. say casting is required System.out.println(b); } } whereas public class b1{ public static void main(String arg[]){ final int i=10; byte b=i;// will compile System.out.println(b); } } why is it so. Can anybody explain the reason.
[This message has been edited by Arathi Rajashekar (edited November 29, 2001).]
Arathi<br />Sun Certified Java Programmer
Darryl Failla
Ranch Hand
Joined: Oct 16, 2001
Posts: 127
posted
0
final short j=10; This compiles and runs properly for me.
Darryl Failla
Sun Certified Java 2 Programmer
Nain Hwu
Ranch Hand
Joined: Sep 16, 2001
Posts: 139
posted
0
Arathi, Which version of compiler are you using? JDK1.3.1 or later should compile following code without problem: