public static void main(String[] args) {
// TODO Auto-generated method stub
//Scanner for AccountNumbers
Scanner AccountIn = new Scanner(System.in);
ArrayList<String> AccountNumber = new ArrayList<String>();
System.out.println("Create Account Number");
while(AccountIn.hasNextLine()>0 &&AccountIn.hasNextLine() < 9){
//EveryTime AccountNumber Is created store in Array
AccountNumber.add(AccountIn.nextLine());
money = reader.readDouble("Enter Starting Amount Of Money");
}
}
我想获得用户扫描仪'AccountIn'的输入大于0小于9我该怎么做?我应该创建一个输入变量,然后在while循环中列出吗?还是应该使用try和catch异常?JAVA - 如何设置用户输入的输入范围验证
你想检查'AccountIn'中的章程吗? –
是的。 AccountIn是用户输入账号的扫描仪。 – Ahmed
@Ahmed看看我的解决方案。 – user3437460