Java List shuffle

Description

Java List shuffle

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
  public static void main(String args[]) {
    List<Integer> dataList = new ArrayList<Integer>();
    dataList.add(1);//from w w w .j  a v  a  2 s .co m
    dataList.add(2);
    dataList.add(3);
    dataList.add(4);
    dataList.add(5);
    
    System.out.println(dataList);
    
    Collections.shuffle(dataList);
    System.out.println(dataList);
    
    Collections.shuffle(dataList);
    System.out.println(dataList);
  }
}



PreviousNext

Related