System.out.println("Please enter the amount of money you have here: ");
Scanner have = new Scanner(System.in);
System.out.println("Please enter your starting bet here: ");
Scanner rate = new Scanner(System.in);
int moneyHad = Integer.parseInt(have.next());
int moneyRate = Integer.parseInt(rate.next());
System.out.println(moneyHad + ", " + moneyRate);
有我的代码,这是我的输出。Java - 扫描器不要求输入
Please enter the amount of money you have here:
Please enter your starting bet here: 1
1
1, 1
正如你可以看到它打印它们都在它要求之前,这就是为什么没有输入第1行的输入。
请快点帮帮我吧!
你为什么要创建两个'Scanner'对象? – Abubakkar
只要看看代码行的顺序,并考虑每行代码的作用。或者使用调试器,以获得更深入的洞察力。一旦你完成了这个任务,就不应该太难找到问题所在。并且'Scanner'上的提示:在同一个'InputStream'上的多个扫描仪很可能会导致一些问题,并且首先不需要两个扫描仪。 – Paul
Abubakkar Rangara,因为我需要2个输入。 – mobinblack