Understanding difference between List & Set


This is a basic question for novice programmer to the experienced. Thought question got very famous with Java Collections, but the concept of List and Set goes way before.

  • What is List and Set? List and Set are data-structures aimed at storing a series of values which can be accessed sequentially either from head / tail ( mostly from head of the structure).

  • When to use List and Set.

    • Use Set when you need unique values in the collection.

    • Use List when you are not bothered about uniqueness of the collection

Published on: