List of usage examples for java.util Collections shuffle
public static void shuffle(List<?> list)
From source file:Main.java
public static void main(String[] argv) throws Exception { String[] array = new String[] { "a", "b", "c" }; Collections.shuffle(Arrays.asList(array)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { List list = new ArrayList(); Collections.shuffle(list); }
From source file:MainClass.java
public static void main(String[] args) { List<String> argList = Arrays.asList(args); Collections.shuffle(argList); for (String arg : argList) { System.out.format("%s ", arg); }//from w ww . jav a 2 s . c om System.out.println(); }
From source file:Main.java
public static void main(String[] args) { String[] peoples = { "A", "B", "C", "D", "E", "F" }; List<String> names = Arrays.asList(peoples); Collections.shuffle(names); for (String name : names) { System.out.print(name + " "); }/* w w w. j a v a 2 s . com*/ }
From source file:Shuffle.java
public static void main(String args[]) { String[] strArray = new String[] { "Java", "Source", "And", "and", "Support", "java2s" }; List l = Arrays.asList(strArray); Collections.shuffle(l); System.out.println(l);//from w w w . java2s.c o m }
From source file:Main.java
public static void main(String[] args) { String[] alphabets = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; List<String> list = Arrays.asList(alphabets); Collections.shuffle(list); for (String alpha : list) { System.out.print(alpha + " "); }/*from ww w .j av a2 s . co m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { List<Integer> list = new ArrayList<Integer>(); for (int i = 1; i <= 12; i++) list.add(new Integer(i)); Collections.shuffle(list); System.out.println(list);/* w w w. j a va2s .com*/ }
From source file:Main.java
public static void main(String args[]) { List<Character> ll = new LinkedList<Character>(); for (char n = 'A'; n <= 'Z'; n++) ll.add(n);//www . j a v a2 s. c om Collections.shuffle(ll); for (Character x : ll) System.out.print(x + " "); Collections.sort(ll); for (Character x : ll) System.out.print(x + " "); System.out.println("Searching for F."); int i = Collections.binarySearch(ll, 'F'); if (i >= 0) { System.out.println("Found at index " + i); System.out.println("Object is " + ll.get(i)); } }
From source file:Main.java
public static void main(String args[]) { List<Integer> dataList = new ArrayList<Integer>(); for (int i = 0; i < 10; i++) { dataList.add(i);//from www . j a v a 2 s.c o m } Collections.shuffle(dataList); int[] num = new int[dataList.size()]; for (int i = 0; i < dataList.size(); i++) { num[i] = dataList.get(i); } System.out.println(Arrays.toString(num)); }
From source file:Main.java
public static void main(String[] args) { List<String> list = new ArrayList<>(); list.add("Java"); list.add("R"); list.add("CSS"); list.add("XML"); Collections.sort(list);/*from w w w.ja v a 2 s .c o m*/ System.out.println("List: " + list); Collections.shuffle(list); System.out.println("List: " + list); Collections.shuffle(list); System.out.println("List: " + list); }