posted 16 years ago
Phal,
I think here you are trying to differentiate between octal and int taking them as separate datatypes, when you say "Then why are the cases considered as octal instead of int?"
Decimal, Octal and Hexadecimal are just different representations using which one can write integer literals.ex:base 10 - decimal,8 - octal and 16 - hexadecimal
The values in the case statements are considered as octal representation of int, as they are prefixed with 0, instead of the normal decimal representation of int which would be without prefixing 0.
So adding to what pankaj said, when value is 09 ,it is an octal representation of an integer number but not a valid one.Because, an octal integer literal begins with the digit 0 and contains any of the digits 0 through 7.That is why you must have got the compiler error.
Hope this helps.
[ July 14, 2008: Message edited by: Meena Subramanian ]