Как я могу избежать «я не могу быть преобразован в переменную» в Java? [закрыто]JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Как я могу избежать «я не могу быть преобразован в переменную» в Java? [закрыто]

Сообщение Anonymous »

Вот мой код:

Код: Выделить всё

import java.io.*;
import java.util.*;

public class CheckPassword {
public static void PasswordValidator(String password) {
int n = password.length();
boolean hasDigit = false, specialChar = false, hasLetter = false;
Set set = new HashSet(Arrays.asList('!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+'));
for (char i : password.toCharArray()) {
if (Character.isLetter(i))
hasLetter = true;
if (Character.isDigit(i))
hasDigit = true;
if (set.contains(i))
specialChar = true;
}
int onlydigit = 0;
int onlyletter = 0;
if (n >= 1) {
for (i = 0; i < n; i++) {
char x = password.charAt(i);
if (Character.isDigit(x)) {
onlydigit++;
}
if (Character.isLetter(x)) {
onlyletter++;
}
}
}
System.out.print("Your password " + '"' + password + '"' + " is ");
if (n < 8) {
if (n == onlydigit) {
System.out.println("very weak");
} else {
System.out.println("weak");
}
} else {
if ((hasDigit == true) && (hasLetter == true)) {
if ((onlydigit + onlyletter) == n) {
System.out.println("strong");
} else {
if (specialChar == true) {
System.out.println("very strong");
}
}

}
}
}

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("ENTER YOUR PASSWORD: ");
String password = sc.nextLine();
PasswordValidator(password);
}
}
Код Visual Studio выдает следующую ошибку:

Код: Выделить всё

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
i cannot be resolved to a variable
i cannot be resolved to a variable
i cannot be resolved to a variable
i cannot be resolved to a variable
at CheckPassword.PasswordValidator(CheckPassword.java:21)
at CheckPassword.main(CheckPassword.java:56)
Как избежать этой ошибки?

Подробнее здесь: https://stackoverflow.com/questions/667 ... le-in-java
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»