1. I made List readyPasswords class variable and got this.
2. readyPasswords was methods variable before. But I had this when validated
My code seems to work well, but it doesn't pass validation


package com.codegym.task.task32.task3204;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/*
Password generator
*/
public class Solution {
static List<Integer[]> readyPasswords = new ArrayList<>();
public static void main(String[] args) {
ByteArrayOutputStream password = getPassword();
System.out.println(password.toString());
}
public static ByteArrayOutputStream getPassword() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
boolean containDigit = false;
boolean containLC = false;
boolean containUC = false;
Integer[] chars = new Integer[8];
for (int i = 0; i < chars.length; i++) {
chars[i] = getCharCode();
}
for (Integer symbol : chars) {
if (symbol >= 'a' && symbol <= 'z') {
containLC = true;
}
if (symbol >= '0' && symbol <= '9') {
containDigit = true;
}
if (symbol >= 'A' && symbol <= 'Z') {
containUC = true;
}
}
if (!containLC || !containDigit || !containUC) {
getPassword();
}
if (readyPasswords.isEmpty()) {
readyPasswords.add(chars);
} else {
for (Integer[] readyPassword : readyPasswords) {
int matchcounter = 0;
for (int i = 0; i < chars.length; i++) {
if (!chars[i].equals(readyPassword[i])) {
continue;
} else {
matchcounter++;
}
}
if (matchcounter == 8) {
getPassword();
} else {
readyPasswords.add(chars);
}
}
}
for (Integer symbol : chars) {
outputStream.write(symbol);
}
return outputStream;
}
public static int getCharCode() {
Random r = new Random();
int ch1;
final int DIGITS_GROUP = 0;
final int LOWERCASE_LETTERS_GROUP = 1;
final int UPPERCASE_LETTERS_GROUP = 2;
ch1 = r.nextInt(3);
switch (ch1) {
case DIGITS_GROUP:
ch1 = r.nextInt(10) + '0';
return ch1;
case LOWERCASE_LETTERS_GROUP:
ch1 = r.nextInt(26) + 'a';
return ch1;
case UPPERCASE_LETTERS_GROUP:
ch1 = r.nextInt(26) + 'A';
return ch1;
}
return ch1;
}
}