我有一个代码,其中switch语句测试的依赖于数组变量:
String shuff = Import.shuffle();
String[] form = new String[95];
for(int i = 0; i < 95; i++)
{
form[i] = Format.shuffle(shuff, i);
}
switch(str)
{
case "a":
x = 6;
break;
case "b":
x = 16;
break;
case "c":
x = 23;
break;
//So on and so forth
}
Run Code Online (Sandbox Code Playgroud)
我想做的是采用数组形式[]并将其用作案例:
String shuff = Import.shuffle();
String[] form = new String[95];
for(int i = 0; i < 95; i++)
{
form[i] = Format.shuffle(shuff, i);
}
switch(str)
{
case form[0]:
x = …Run Code Online (Sandbox Code Playgroud) java ×1