0
누군가가이 문제가 무엇인지 말해 줄 수 있습니까? 나는 j++
이 증가 할 수 없으므로 j
을 0으로 남겨두고 있다고 느끼지만, 확실하지 않습니다.사용자 이름 확인 오류
약 2 분 안에 초안을 작성한 수업에 사용하고 있습니다. 무엇이 잘못되었을 수 있습니까? 이건 내 코드입니다 :
public static String[] names = { "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z" };
//A to Z
public static String[] check = { "a","zz" };//Purposely errors a and z, runs the whole check to make sure it works
public static void usernameCheck() {
int errorCount = 0;
for(int i = 0; i < check.length;) {
for(int j = 0; j < names.length; j++) {
if(check[i].toLowerCase().equals(names[j].toLowerCase())) {
System.out.println("Username " + check[i] + " is already in use");
System.out.println(i + " and " + j);//Just a check if i or j is increasing at all
errorCount++;
}
if(j == names.length) {
System.out.println("Moving to next username");
j = 0;
i++;
}
}
}
if(errorCount > 0) {
System.out.println(errorCount + " Errors Occured");
System.out.println("Please consider revising usernames and try again.");
}else
System.out.println("Run Successful, no errors have occured.");
}
public static void main (String[] args) {
usernameCheck();
}
i의 목적은 j가 길이를 끝낼 때까지 0을 유지하는 것입니다. j가 완전히 읽히고 0으로 재설정 된 후에 모든 값을 확인한 후 다음 검사로 이동해야하기 때문에 길이를 늘립니다. – Abszol