Basic Level Questions
Basic Level Questions
Accessing Access via index Access via iteration Access via key
Elements
Feature List Set Map
(list.get(index)) (map.get(key))
When key-value
When you need an
When uniqueness is required, relationships are required,
Best Use Cases ordered collection, e.g., a
e.g., storing unique IDs e.g., dictionary-like
list of items
storage
HashMap,
Common ArrayList, HashSet, LinkedHashSet,
LinkedHashMap,
Implementations LinkedList, Vector TreeSet
TreeMap, Hashtable