Skip to content
Justice Tech School

List, Set, Queue and Deque

The Collections Framework offers List (ordered), Set (unique), Queue and Deque (FIFO and double ended) implementations such as ArrayList, LinkedList, HashSet, TreeSet and ArrayDeque.

Example
import java.util.*;
List<Integer> list = new ArrayList<>(List.of(3, 1, 2));
Collections.sort(list);
Set<String> set = new TreeSet<>(List.of("b", "a", "b"));
Deque<Integer> dq = new ArrayDeque<>();
dq.addFirst(1); dq.addLast(2); dq.push(0);
System.out.println(list + " " + set + " " + dq + " " + dq.pop());

Result

[1, 2, 3] [a, b] [0, 1, 2] 0

Exercise

Keep unique sorted values.

Set<String> s = new <>()

Quiz Test

Which keeps unique values?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.