我开发了一个拒绝以00和99开头的数字的函数。

public Boolean valideCode(EditText code_postal){

    String number =     code_postal.getText().toString();

    if (number.charAt(0)==00){


    }

    return false;

}


我如何正确实现此功能。

最佳答案

if语句将始终返回false。

一种解决方案:

if (number.trim().startsWith("00") || number.trim().startsWith("99")){
  System.out.println("not valid");
}

关于java - 检查前两位数字在00 && 99之间,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16978134/

10-12 00:22
查看更多