Вроде же все генерируется.
package com.javarush.task.task32.task3204;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Random;
import java.util.stream.IntStream;
/*
Генератор паролей
*/
public class Solution {
public static void main(String[] args) throws IOException {
ByteArrayOutputStream password = getPassword();
System.out.println(password.toString());
}
public static ByteArrayOutputStream getPassword() throws IOException {
String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
ByteArrayOutputStream pass = new ByteArrayOutputStream();
for(int i=0; i<8; i++){
int c = rnd(1);
int r = rnd(s.length()-1);
char passChar =s.charAt(r);
if(c==0){
pass.write(Character.toString(passChar).toLowerCase().getBytes());
} else {
pass.write(passChar);
}
}
return pass;
}
public static int rnd(int max)
{
return (int) (Math.random() * ++max);
}
}