【发布时间】:2015-11-09 18:42:59
【问题描述】:
我想排除除字母和数字之外的任何字符,但是当我运行程序时,无论我输入什么,我总是进入 while 循环。
System.out.println("Please enter the name of the next dancer");
while(!scan.hasNext("^[a-z0-9]+$/i"))
{
System.out.println("Please ensure you only enter letters of the alphabet and numbers bewteen 0 and 9");
scan.nextLine();
}
arrCelebs[celeb] = scan.next();
例如我输入“a”我得到 - System.out.println("请输入下一位舞者的名字");
如果我输入“%”也是一样的
【问题讨论】:
-
只是语义,但只要我们说的是十进制数,除了0到9之间还有其他数字吗? :)