Friday, 4 April 2014

Set Vs List

  1. A List is a ordered collection of Elements. Where as Set is a distinct list of elements which is unordered.
  2. List can contain duplicates where as Set contains only unique elements.
  3. List supports positional access(i.e, Just like Arrays we can access List data using index), Where as Set not support Positional access.
  4. List provides iterator such that both backward and forward traversal possible.
  5. Popular implementation of List interface in Java includes ArrayList, Vector and LinkedList. While popular implementation of Set interface includes HashSet, TreeSet and LinkedHashSet.
  6. 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.
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment