为什么它告诉我无法比较整数?我试图在这里比较这一行,但它不会让我得到的只是:
if (counter1 = 0 || counter2 = 0)
{
return false;
}
这是我的其余代码供引用。
public static boolean checkPassword(String password){
int length;
length = password.length();
if (length < 6 || length > 11){
System.out.println("Password must be 6 - 10 characters long!");
return false;
}
int counter1 = 0;
for (int i = 0; i < password.length(); i++){
if (Character.isLetter(password.charAt(i)))
counter1++;
}
int counter2 = 0;
for (int i = 0; i < password.length(); i++){
if(Character.isDigit(password.charAt(i)))
counter2++;
}
if (counter1 = 0 || counter2 = 0)
{
return false;
}
return true;
}
我不断收到未定义的标记来帮助我:)
最佳答案
您没有使用相等测试==
,而是使用赋值运算符=
。这是初学者很常见的错误。
if (counter1 == 0 || counter2 == 0) {
return false;
}
关于java - 无法在 Java 野生错误标记中使用 If 语句对参数未定义进行比较?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4893241/