List of usage examples for java.util Collections reverse
@SuppressWarnings({ "rawtypes", "unchecked" }) public static void reverse(List<?> list)
This method runs in linear time.
From source file:MainClass.java
public static void main(String[] a) { List barFlies = Arrays.asList(new String[] { "A", "B", "C" }); Collections.reverse(barFlies); System.out.println(barFlies); }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("A");/*w w w .j ava 2 s .co m*/ v.add("B"); v.add("C"); v.add("D"); v.add("E"); System.out.println(v); Collections.reverse(v); System.out.println(v); }
From source file:Main.java
public static void main(String args[]) { List<Character> ll = new LinkedList<Character>(); for (char n = 'A'; n <= 'F'; n++) ll.add(n);//from w w w.j ava 2s . com System.out.println(ll); Collections.reverse(ll); System.out.println(ll); Collections.rotate(ll, 2); System.out.println(ll); Collections.shuffle(ll); System.out.println(ll); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("A"); arrayList.add("B"); arrayList.add("C"); arrayList.add("D"); arrayList.add("E"); System.out.println(arrayList); Collections.reverse(arrayList); System.out.println(arrayList); }
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 va 2 s .c om*/ System.out.println("List: " + list); Collections.reverse(list); System.out.println("List: " + list); }
From source file:Main.java
public static void main(String args[]) { List<Character> ll = new LinkedList<Character>(); for (char n = 'A'; n <= 'F'; n++) ll.add(n);/*from w w w . j av a 2 s.co m*/ System.out.println("Here is the original list: "); for (Character x : ll) System.out.print(x + " "); Collections.reverse(ll); System.out.println("Here is the reversed list: "); for (Character x : ll) System.out.print(x + " "); Collections.rotate(ll, 2); for (Character x : ll) System.out.print(x + " "); Collections.shuffle(ll); System.out.println("Here is the randomized list:"); for (Character x : ll) System.out.print(x + " "); }
From source file:UtilDemo3.java
public static void main(String[] args) { String[] coins = { "A", "B", "C", "D", "E" }; List l = new ArrayList(); for (int i = 0; i < coins.length; i++) l.add(coins[i]);// w ww. j a va 2 s . c om ListIterator liter = l.listIterator(); while (liter.hasNext()) System.out.println(liter.next()); Collections.reverse(l); liter = l.listIterator(); while (liter.hasNext()) System.out.println(liter.next()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String[] strArray = new String[] { "z", "a", "A" }; List list = Arrays.asList(strArray); Collections.sort(list);// w ww. j av a 2 s .com Collections.sort(list, String.CASE_INSENSITIVE_ORDER); Collections.sort(list, Collections.reverseOrder()); Collections.sort(list, String.CASE_INSENSITIVE_ORDER); Collections.reverse(list); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String[] strArray = new String[] { "z", "a", "A" }; List list = Arrays.asList(strArray); Collections.sort(list);//from w w w.j a va 2 s .com Collections.sort(list, String.CASE_INSENSITIVE_ORDER); Collections.sort(list, Collections.reverseOrder()); Collections.sort(list, String.CASE_INSENSITIVE_ORDER); Collections.reverse(list); }
From source file:Main.java
public static void main(String[] args) { // create array list object List<String> arrlst = new ArrayList<String>(); // populate the list arrlst.add("A"); arrlst.add("B"); arrlst.add("C"); arrlst.add("D"); arrlst.add("from java2s.com"); System.out.println("The initial list is :" + arrlst); // reverse the list Collections.reverse(arrlst); System.out.println("The Reverse List is :" + arrlst); }