Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsShuffleExample3 { public static void main(String[] args) { //Create linked list object LinkedList
list = new LinkedList
(); //Add values in the list list.add(45); list.add(20); list.add(55); list.add(90); list.add(15); System.out.println("List before Shuffle = "+list); //We use Random() to shuffle given list. Collections.shuffle(list, new Random()); System.out.println("Shuffled List with Random() = "+list); //We use Random(3) to shuffle given list. Collections.shuffle(list, new Random(3)); System.out.println("Shuffled List with Random(3) = "+list); } }
Output