Hello. I have this question. I want to make char fill with Random but with as many values as the user wants. Faced the problem that always returns only one value, since each time going into a cycle, the value is rewritten and in fact the last is saved.
private static char codeGenerator(int needCharacters) { Random r = new Random(); String alphabet = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (int i = 0; i < needCharacters; i++) { generatedCode = alphabet.charAt(r.nextInt(alphabet.length())); } return generatedCode; }