Collection & null

Can a Hashtable have a “null” key? Can a TreeSet hold a null? Confused?
Check the following table to know whether different data structures support null or not.
Collection Key Value
HashMap Yes [...]

Java performance tips - Part 2 : Better String handling

StringBuffer vs String
As we all know both String & StringBuffer are used to hold string (character sequence) values. The basic & the most important difference between the objects being created using String & StringBuffer : objects of String are immutable (means, no one can change it); but the objects created using StringBuffer are mutable. Consider [...]

Java performance tips - Part 1 : Vector, ArrayList & LinkedList

When, where & how to use Vector & ArrayList
Even though both Vector & ArrayList are used for the same purpose - as a dynamic collection of related objects - there is a right time and place to use them. As we all know there is a major difference: Vector is thread-safe but ArrayList is not. [...]

TreeMap vs HashMap

Both TreeMap & HashMap are two different implementation of the Map interface. Even though this post is titled “TreeMap vs HashMap” I would like to say how they are connected and how much similar they are.
Both TreeMap & HashMap are not synchronized. To make it synchronized we have to explicitly call Collections.synchronizedMap( mapName ) . [...]