Constant expressions are used as case labels in switch statements (
§14.11 ) and have a special significance for assignment conversion (
§5.2 ) and .....
Definition of Constant Expression §15.28
A compile-time constant expression is an expression denoting a value
of primitive type or a String that does not complete abruptly.
Now in above scenario compiler is looking for constant expression as it should be know to the compiler at the compile time.As stated Integer
is actually not a constant Expression for the compiler.