Java switch 语句来处理两个变量?
2022-09-04 19:56:21
我正在寻找一种使用单个开关处理两个字符串的方法,我认为这在Java中是不可能的。
以下是一些伪代码,我想仅通过开关实现。
int s1Value = 0;
int s2Value = 0;
String s1 = "a";
String s2 = "g";
switch (s1 || s2) {
case "a": s1value = 0; s2value = 0; break;
case "b": s1value = 1; s2value = 1; break;
case "c": s1value = 2; s2value = 2; break;
case "d": s1value = 3; s2value = 3; break;
case "e": s1value = 4; s2value = 4; break;
case "f": s1value = 5; s2value = 5; break;
case "g": s1value = 6; s2value = 6; break;
}