我试图在switch语句中更改字符串变量,如下所示:
ArrayList<String> listOfWeightLocations = new ArrayList<String>();
String weight;
ArrayList.add(weight);
Switch (num) {
case 1:
weight = "This";
break;
case 2:
weight = "Other.";
break;
default:
weight = "Another Either."
break;
}
System.out.println(String.valueOf(listOfWeightLocations.get(0));
但它永远不会改变价值观。它保持为空。