List<int> numberList=[]; Random random = new Random(); while(numberList.length<5){ int random_number = randomizer.nextInt(50); if (!numberList.contains(random_number)){ numberList.add(random_number); } }