Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

public class Main {
    public static void main(String args[]) {
        // create Linked List
        List<Integer> list = new LinkedList<Integer>();

        // populate list
        list.add(5);
        list.add(2);
        list.add(1);
        list.add(-3);

        System.out.println("List before shuffle: " + list);

        // shuffle the list
        Collections.shuffle(list, new Random());

        System.out.println("List after shuffle: " + list);
    }
}