View RSS Feed


Java collection tutorials

  1. Java collection Best Practices?

    by , 01-08-2012 at 12:22 PM
    Following are the best practices related to collection framework.

    Use ArrayLists, HashMap when required to avoid thread synchronization overhead. Also you can use arrays when possible. You can achieve thread synchronization by:

    Java Code: This is an example of list and map
    Map myMap = Collections.synchronizedMap(myMap);
    List myList = Collections.synchronizedList(myList);
    Specify the initial values for ArrayList and HashMap because these grow periodically to get space for ...

    Updated 01-15-2012 at 09:35 AM by Java Collection

  2. Java Collection Framework

    by , 01-08-2012 at 12:19 PM
    List, Map and Set are the core interfaces supported by collection framework. Collection interface is extended by List and Set. There is also a Collections class in java that is a utility class and does not confuse it.
    A Set contains only unique elements and prevents duplication. Set is implemented by HashSet and TreeSet. List is a collection of ordered elements and it may contain duplicates. List is implemented by ArrayList, LinkedList and Vector.

    Map supports key value mapping. ...
  3. Sorting Collections

    by , 11-29-2011 at 06:23 PM
    If you are interested in sorting your collections, the good news is that since the inception of Java 5 it is now possible for collections and arrays to be sorted. This is very useful because it is a hell of a lot easier to find something in a sorted set than in an unsorted set. There are a number of sorting algorithms that can be used for your collections. There are listed below.
    • Bubble Sort algorithm
    • Bi-direction Bubble Sort algorithm
    • Quick Sort algorithm
    • Generic Sorting algorithm
    Tutorial , Sorting
  4. Using a Collection vs. Using an Iterator

    by , 11-28-2011 at 07:36 PM
    In this tip, we will look at determining the appropriate use of a collection versus using an iterator. One of the main reasons for using an interface is that you can create more generic and flexible code. By writing to an interface rather than an implementation, you can reuse your code for more types of objects.

    The root interface for all sequence containers is Collection. The java.utiLAbstractCollection class provides a default implementation for a Collection, so that you can create ...