This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Here the byte argument in switch() is not promoted to int...Remember switch() takes char,byte,short and int( and as of Java 5 enum too) as expression.
What the error msg means is that 128 is a int as the range of byte is from -128 to 127....So all its saying is that it found 128 which is a int...but it was expecting a byte ie. < 128...That is why it fails. [ April 23, 2007: Message edited by: megha joshi ]
Hi jinesh, Remeber two important rules of switch 1)Switch expression should be of any type that can be implicitly cast to an int 2)A case constant shold be of same type as that of the switch expression
Now in your example a)swaitch(b+c) results to an int b) and case constant 128 is in range of an int
Cheers<br />-------------<br />Swapnil<br /> <br />SCJP5-81%<br /> <br />"Dictionary is the only place where Success come before Work"