Sobes.tech
Junior

What collection framework interfaces do you know? What common parent do List, Set, Queue, Map have?

sobes.tech AI

Answer from AI

In the Java Collection Framework, the main interfaces are:

  • Collection — the base interface for most collections (except Map).
  • List — an ordered collection that allows duplicates (e.g., ArrayList, LinkedList).
  • Set — a collection of unique elements (e.g., HashSet, TreeSet).
  • Queue — a collection for storing elements in processing order (e.g., LinkedList, PriorityQueue).
  • Deque — a double-ended queue.
  • Map — a collection of key-value pairs, does not inherit from Collection.

Common parent interfaces:

  • List, Set, and Queue inherit from the Collection interface.
  • Map does not inherit from Collection but is part of the Collection Framework.

Example:

List<String> list = new ArrayList<>();
Set<Integer> set = new HashSet<>();
Queue<Double> queue = new LinkedList<>();
Map<String, Integer> map = new HashMap<>();
What collection framework interfaces do you know… - sobes.tech