Wrappers in switch statement
问题 I have a question about objects in a switch statement. I am aware that variables used in case clause must be final (otherwise we get: "case expressions must be constant expressions"). Final on objects means only reference can't be changed, the value still can be changed by other non final reference therefore, we cant use objects in 'case'. But why cant we use wrappers? They are immutable arent they? java code: Integer i = 8; final int x = 10; switch ( x ) { case x: System.out.println("x");