Hi Denish,
My reaction to your specific querry is as follows:
The expression in the
<code> switch(expression) { case lable: }</code> must be an integral type, i.e., it should be a data type that can
be promoted to an "int" viz., char, byte, short, int. The case
<code>lable </code> must be assignable to the type of integral statement. It
cannot be boolean, long or floating point.
For more details on switch construct please visit the JLS section
14.10 at
<A HREF="http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#35518</a >" TARGET=_blank>http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#35518 link.
In light of above, refer to your code, <code>
switch(x)</code>. The expression "x" got promoted to "int" no
need to explicitely cast to int (implicite widening takes place).
However, in the second case
Hope this clarifies your querry.
Ravindra Mohan
[This message has been edited by Ravindra Mohan (edited May 08, 2001).]