我正在尝试根据我的数组值运行 switch 语句。
我需要做一个while循环,遍历我的整个数组,如果数组位value = 0我需要它运行case 0
,如果value = 1我需要它运行位case 1
我需要运行 while 循环,直到它完成对数组值和相应的 case 切换函数的运行
我正在处理的代码:
Scanner scan = new Scanner(System.in);
System.out.println("What position do you want the top card to be moved to?");
System.out.println("Enter \"1\", \"2\", \"3\", \"4\" or \"5\"");
int i = scan.nextInt();
int in = i -1;
//System.out.println(i);
String binaryString = Integer.toBinaryString(in);
System.out.println(binaryString);
int foo = Integer.parseInt(binaryString, 2);
System.out.println(foo);
String[] array = binaryString.split("\\|", -1);
System.out.println(Arrays.toString(array));
switch (foo) {
case 0:
cardForceOutShuffle();
index = 51;
break;
case 1:
cardForceInShuffle();
index = 51;
break;
}
请帮忙。