do{
out.println("\n---------------------------------");
out.println("---------------------------------");
out.print("Please type your acces card number: ");
try{
card = input.nextInt();
if(card.length != 10){
out.println("The number you typed is incorrect");
out.println("The number must be 10 numbers long");
continue;
}
}
catch(InputMismatchException ex){
}
}while(true);
我试图让卡号长度为10位,例如(1234567890),如果用户输入了(123)或(123456789098723),则应该出现错误消息。 card.length似乎不起作用。