Exception in thread "main" java.util.NoSuchElementException, Java我运行时报错
publicstaticvoidplaying(Stringnuser[],Stringnplayer1[],Stringnplayer2[],Stringdeck[],...
public static void playing(String nuser[], String nplayer1[], String nplayer2[], String deck[], int z) {
Scanner input = new Scanner(System.in);
if (z == 1) {
for (int j = 0; j < 100000; j++) {
for (int k = 0; k < 100000; k++) {
System.out.println("It's your turn. Please play card(s):");
p = input.next();
if (p.equalsIgnoreCase("0")) {
for (int i = 0; i < 54; i++) {
if (p.equalsIgnoreCase(deck[i])) {
c = i;
i=54;
}
else{
System.out.println("The card you enter is wrong.");
p=input.nextLine();
i--;
}
}
if (c <= b) {
System.out.println("The card you enter is wrong.");
k--;
} else if (c > b) {
for (int i = 0; i < 18; i++) {
if (p.equalsIgnoreCase(nuser[i])) {
ulist.remove(i);
b = c;
}
}
if (ulist.isEmpty()) {
System.out.println("You are the winner!");
k = 100000;
j = 100000;
} else {
for (int i = 0; i < 18; i++) {
if (p1[i] > b) {
System.out.println("Player1 is playing:" + nplayer1[i]);
p1list.remove(i);
b = p1[i];
i = 18;
}
}
if (p1list.isEmpty()) {
System.out.println("Player1 is the winner!");
k = 100000;
j = 10000;
} else {
for (int i = 0; i < 18; i++) {
if (p2[i] > b) {
System.out.println("Player2 is playing:" + nplayer2[i]);
p2list.remove(i);
b = p2[i];
i = 18;
}
}
if (p2list.isEmpty()) {
System.out.println("Player2 is the winner!");
k = 100000;
j = 100000;
}
System.out.println("This is your new cards:");
System.out.print(ulist);
System.out.println("");
}
}
}
}
}
}
}
}
}
我删减了一些内容,重点是p = input.next();可能有问题,这个就是237行。 展开
Scanner input = new Scanner(System.in);
if (z == 1) {
for (int j = 0; j < 100000; j++) {
for (int k = 0; k < 100000; k++) {
System.out.println("It's your turn. Please play card(s):");
p = input.next();
if (p.equalsIgnoreCase("0")) {
for (int i = 0; i < 54; i++) {
if (p.equalsIgnoreCase(deck[i])) {
c = i;
i=54;
}
else{
System.out.println("The card you enter is wrong.");
p=input.nextLine();
i--;
}
}
if (c <= b) {
System.out.println("The card you enter is wrong.");
k--;
} else if (c > b) {
for (int i = 0; i < 18; i++) {
if (p.equalsIgnoreCase(nuser[i])) {
ulist.remove(i);
b = c;
}
}
if (ulist.isEmpty()) {
System.out.println("You are the winner!");
k = 100000;
j = 100000;
} else {
for (int i = 0; i < 18; i++) {
if (p1[i] > b) {
System.out.println("Player1 is playing:" + nplayer1[i]);
p1list.remove(i);
b = p1[i];
i = 18;
}
}
if (p1list.isEmpty()) {
System.out.println("Player1 is the winner!");
k = 100000;
j = 10000;
} else {
for (int i = 0; i < 18; i++) {
if (p2[i] > b) {
System.out.println("Player2 is playing:" + nplayer2[i]);
p2list.remove(i);
b = p2[i];
i = 18;
}
}
if (p2list.isEmpty()) {
System.out.println("Player2 is the winner!");
k = 100000;
j = 100000;
}
System.out.println("This is your new cards:");
System.out.print(ulist);
System.out.println("");
}
}
}
}
}
}
}
}
}
我删减了一些内容,重点是p = input.next();可能有问题,这个就是237行。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询