Stating the difference of common Java tools

Here are some common objects in Java that are used.  It is better to know the difference of some very similar objects with almost the same functionality.

1.) StringBuilder and StringBuffer

StringBuilder is faster than StringBuffer, becasue StringBuilder is not synchronized, but be careful it is not thread safe.  Then everything else is the similarly the same in terms of functionality. It can append, delete, and concatenate Strings. Therefore you may decide which is suited for your usage.

2.) HashTable and HashMap

This one is also has the difference of not synchronized and thread safe. HashMap performs faster… but then its non synchronized. HashTable would be the opposite then.  There is also the ConcurrentHashMap which an new version of HashTable. Other difference is that HashTable does not allow null.

3.) List and Collections

Basically List just inherits the Collection class.  List and Collection can do these:

a. ) add and remove items ( in First-in-First-out basis )
b. ) iterate and query its size

But here ‘s what add on to the List ( Only List can do )

a. ) get element in a specified position
b. ) add / delete an element in a specified postion

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s