Hello, this code returns 6 values between 1 and 60 without repeating and in order. But for numbers smaller than 10 I'd like to add 0 before type: 01.02 ... 10. I tried to use String.format () but it gives error when compiling.
Thank you.
private static String sortear() {
Set<Integer> numberset = new HashSet<>();
Random random = new Random();
while (numberset.size() < 6) {
numberset.add((random.nextInt(60) + 1));
}
ArrayList<Integer> jogo = new ArrayList<>(numberset);
Collections.sort(jogo);
String vetor = Arrays.toString(jogo.toArray());
return vetor;
}