I assume that menu is a string type, although in reality this does not match the statements of your case. Permission to use strings in switch been added in Java 7.
You can switch to Java 7 and fix the case so that it checks the string and not the integral 1 , or converts menu to an integer and checks, for example, with Integer.ParseInt() , something like:
String menu = "1"; int menuint; try { menuint = Integer.ParseInt (menu); } catch (NumberFormatException e) { menuint = -1; } switch (menuint) { :
source share