This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
The below Code is giving compile time error because 128 is not in byte range. But I read that switch will type cast it to int by default. So in this case byte will cast to int and 128 is in the range of int.If I am wrong,please advice on this
public class SwitchDemo { public static void main(String args[]) { byte g = 2; switch(g) { case 23: case 128: }} }
Thanks in Advance
dhwani mathur
Ranch Hand
Joined: May 08, 2007
Posts: 621
posted
0
Hi sridhar
you said the below shown code gives you compile time error than how is it possible that switch can cast an byte to int if it must have casted than i think you must have not got the compile time error .......isnt it?