Hi this shows are to shuffle the contents of an array list so I made a little program to show it's usage hope you like it.
Code:import java.util.ArrayList; import java.util.Collections; public class Main { public static void main(String[] args) { //UK lotto ArrayList<Integer>nums = new ArrayList<Integer>(); //Add the numbers 1 to 59 for(int x = 1; x<=59; x++){ nums.add(x); } //Shuffle the nums collection. Collections.shuffle(nums); //Print the first six numbers. for (int x = 1; x <= 6;x++){ System.out.print(nums.get(x) + " "); } } }




Reply With Quote