我似乎有这个问题很多,我不能完全似乎明白了如何工作的扫描仪我的扫描仪会要求输入两次
System.out.println("Please enter a number");
Scanner choice1 = new Scanner(System.in);
int choiceH = choice1.nextInt();
while(!choice1.hasNextInt()){
System.out.println("Please enter a number");
choice1.next();
}
我想要什么的代码做的就是要求一个数,并检查输入是否是一个数字。 我的问题是,它会问号码两次,我不知道为什么。