CopyOnWriteArrayList in Java

What is CopyOnWriteArrayList CopyOnWriteArrayList is a concurrent Collection class introduced in Java 5 Concurrent API. It implements List interface like ArrayList, Vector and LinkedList but it is a thread-safe collection and it achieves its thread-safety in a slightly different way than Vector or other thread-safe collection class. CopyOnWriteArrayList creates a fresh copy of the underlying […]

Read More

Comparator interface in Java

For more information please go through http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html A comparison function, which imposes a total ordering on some collection of objects. Comparators can be passed to a sort method (such as Collections.sort or Arrays.sort) to allow precise control over the sort order. Comparators can also be used to control the order of certain data structures (such […]

Read More

Comparable interface in Java

For more information please go through http://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html This interface imposes a natural ordering on objects of each class that implements it and the class’s compareTo method is referred to as its natural comparison method. Lists or arrays of objects that implement this interface can be sorted automatically by Collections.sort or Arrays.sort respectively. Objects that implement […]

Read More