Submitted by heartin on Thu, 09/13/2012 - 20:03
Both Enumeration and Iterator are interfaces in Java for getting successive elements. Enumeration is older while iterator was introduced later with some improvements. Iterator has taken the place of Enumeration in the Java collections framework. ListIterator is a sub-interface of Iterator and allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list.
Submitted by heartin on Tue, 10/21/2014 - 09:23
Collection framework in Java provides efficient implementations for commonly used data structures like list, set, queue, map etc. We can reuse these implementations without writing our own implementations when we need to use these data structures.
Submitted by heartin on Mon, 10/05/2015 - 22:32
Method equals check if two objects are equal.
String class and most collection classes overrides equal to check if two objects are meaningfully equal, which means, if two different string objects have the same value.
The equals method for class Object will return true, for any non-null reference values x and y, if x and y refer to the same object.
Submitted by heartin on Sat, 10/10/2015 - 00:44
TreeMap is a Red-Black tree based NavigableMap implementation.
Important properties of TreeMap
The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time.
Provides guaranteed log(n) time cost for the containsKey, get, put and remove operations.
Submitted by heartin on Wed, 10/07/2015 - 20:57
Collection Interface is the Root interface in the collection hierarchy.
Important properties Collection interface
JDK does not provide any direct implementations of this interface: it provides implementations of more specific subinterfaces like Set and List etc.
Submitted by heartin on Wed, 10/07/2015 - 21:21
List is an ordered collection.
Important points about List interface
also known as a sequence.
typically allow duplicate
Places additional stipulations on the contracts of the iterator, add, remove, equals, and hashCode methods.
Submitted by heartin on Sun, 10/20/2013 - 05:29
ArrayList is a resizable-array implementation of the List interface.
Submitted by heartin on Sat, 09/05/2015 - 08:18
There are three constructors for creating an ArrayList:
When you create an ArrayList using the constructor ArrayList(), the internal array for storage is created with a size 10.
The constructor ArrayList(int initialCapacity) allows us to set the initial capacity.
Submitted by heartin on Tue, 10/06/2015 - 00:12
You can sort a list of integers based on their natural ordering. You can compare two integers and see which one comes before the other in natural ordering. But how will you compare two objects and sort them in an order. You have two interfaces in Java Comparable and Comparator that will help us compare objects and sort them in an order.
Submitted by heartin on Sat, 10/10/2015 - 00:06
SortedMap interface extends Map interface to further provide a total ordering on its keys.
Important Properties of SortedMap
SortedMap is ordered according to the natural ordering of its keys, or by a Comparator typically provided at sorted map creation time.
Order is reflected when iterating over the sorted map's collection views returned by the entrySet, keySet and values methods.
SortedMap is the map analogue of SortedSet.