Submitted by heartin on Sat, 10/10/2015 - 22:46
TreeSet Class implements NavigableSet and is based on a TreeMap.
Important properties of a TreeMap class
The elements are ordered using their natural ordering, or by a Comparator
Provides guaranteed log(n) time cost for the basic operations like add, remove and contains.
Submitted by heartin on Sat, 10/10/2015 - 19:52
Set is a collection that models the mathematical set abstraction and contains no duplicate elements.
Important properties of Set interface
Sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element.
The Set interface places additional stipulations on:
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 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.
Submitted by heartin on Thu, 10/08/2015 - 09:03
Map is an object that maps keys to values.
Important properties of a Map
A map cannot contain duplicate keys
Each key can map to at most one value.
Map interface takes the place of the abstract Dictionary class.
The order of a map is the order in which the iterators on the map's collection views return their elements.
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 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 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 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 Mon, 10/05/2015 - 12:45
Generics language feature in Java allow you to write a class using generic types which can then be substituted with any type before actually using it. Generics allow you to write reusable and type safe code.
For example, you can write a generic linked list. The data in the linked list can be one of String, Integer or any other class type. The actual type needed to be decided only before using it and while creating the class you need to create only one reusable generic class.