Collections provide a number of static methods for searching, sorting, and converting Collection objects. : Arrays « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » Arrays 
8.21.2.Collections provide a number of static methods for searching, sorting, and converting Collection objects.
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;

public class MainClass {
  public static void main(String args[]) {
    String strings[] "J""E""L""A""P""S""G""B""K""L" };
    Arrays.sort(strings);
    List list = Arrays.asList(strings);
    displayList(list);
  }

  static void displayList(List list) {
    System.out.println("The size of the list is: " + list.size());
    ListIterator i = list.listIterator(0);
    while (i.hasNext()) {
      Object o = i.next();
      if (o == null)
        System.out.println("null");
      else
        System.out.println(o.toString());
    }
  }
}
8.21.Arrays
8.21.1.java.util.Arrays class contains static methods for sorting and searching arrays.
8.21.2.Collections provide a number of static methods for searching, sorting, and converting Collection objects.
8.21.3.Converting Arrays to Lists to Arrays
8.21.4.Searching array with Comparator
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.