Home > java hacks, Uncategorized > Java Collection, List, Set

Java Collection, List, Set

In Java List, Set or Collection all mean collection of items. But there are some subtle difference in them when you put your feet in Java world.

 

In fact, List and Set are special type of Collection in Java. Collection are just group of items where you can add or remove items, search for items and so on.

 

On the other hand, List is a sequential collection of items. For example, you may want to find 5th element from a List which does not carry enough semantics in Collection.

 

On another side, Set is yet another special type of collection where there cannot be any member duplicated. Java Util Set basically give an abstract of mathematical set.

 

Following figure from [1] explains the relation between Collection, Set and List (and others) in term of Java Interface hierarchy.

 

 

ss40

 

 

Reference:

[1] http://way2java.com/wp-content/uploads/2011/06/ss40.png

[2] http://stackoverflow.com/questions/3317381/what-is-the-difference-between-collection-and-list-in-java

Advertisements
Categories: java hacks, Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: