/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Random r = new Random();
        // repete o loop até gerar um array com números repetidos
        while (true) {
            int numero;
            int[] num = new int[6];
            for (int i = 0; i < num.length; i++) {
                numero = r.nextInt(60) + 1;
                for (int j = 0; j < num.length; j++) {
                    if (numero == num[j] && j != i) {
                        numero = r.nextInt(60) + 1;
                    } else {
                        num[i] = numero;
                    }
                }
            }
            if (temRepetidos(num)) { // encontrei, imprime o array e encerra o while
                System.out.println("Ops, tem números repetidos");
                for (int n : num) {
                    System.out.print(n + "  ");
                }
                break;
            }
        }
    }

    // verifica se tem números repetidos
    static boolean temRepetidos(final int[] numeros) {
        Set<Integer> set = new HashSet<Integer>();
        for (int i : numeros) {
            if (set.contains(i))
                return true;
            set.add(i);
        }
        return false;
    }
}