This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The expression in a switch statement should be a compile time constant ie it can take int , byte , char, short ie any type which can be cast into an int . If instead of int i take a byte argument as in the following code :-
This results in compile time error as the case argument 128 is too large for a byte . My question is g has already been implicitly converted to an int . Now so it is an integer which is being compared in the case statement . Then why are we getting the error .
My question is g has already been implicitly converted to an int
No it will not be implicitly converted to an int. The case constants must be assignable to the switch expression. Since the switch expression is of type byte, the value 128 is out of its range so you get an error...