- A List is a ordered collection of Elements. Where as Set is a distinct list of elements which is unordered.
- List can contain duplicates where as Set contains only unique elements.
- List supports positional access(i.e, Just like Arrays we can access List data using index), Where as Set not support Positional access.
- List provides iterator such that both backward and forward traversal possible.
- Popular implementation of List interface in Java includes ArrayList, Vector and LinkedList. While popular implementation of Set interface includes HashSet, TreeSet and LinkedHashSet.
- Two Sets are said to be equal if they contain same elements, Here order doesn't matter. Where as two lists are said to be equal if they contain same elements in the same order.
This blog is primarily focus on Java fundamentals and the libraries built on top of Java programming language. Most of the post are example oriented, hope you have fun in reading my blog....:)
Friday 4 April 2014
Set Vs List
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment