case expressions must be constant expressions , and in given code b is blank final variable , sa at compile time compiler checks the constant expression for case statement, and b get value 2 at run time
There is a difference between 'a' and 'b'. 'a' is initialized with a compile-time constant expression and is final. So we call it 'a constant variable'. 'b' is final but it is blank final variable. A blank final is a final variable whose declaration lacks an initializer.
That's why you cannot use 'b' in the way you are trying to use it.