我正在尝试验证字段名称是否为空,并且它正在工作
while(name.isEmpty()||!name.matches("^([A-Z*a-z]*(\\s))+[A-Z*a-z]*$"))
当我尝试验证字段编号为空时,它会给出错误。
while (number.charAt(0) != '0' || number.length() < 4 || !number.matches("^[0-9]*") || number.isEmpty())
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)