Boolean check[] = new Boolean[50]; int chave[] = new int[5]; for(int i = 0; i < 50; i++) check[i] = false; for(int i = 0; i < 5; i++) { do chave[i] = 1 + 50 * Math.random(); // Math.random gera numeros entre [0 e 1[ while(check[chave[i] - 1]); check[chave[i] - 1] = true; }