Java : SequencedSet with Examples
SequencedSet (Java SE 21 & JDK 21) with Examples.
You will find code examples on most SequencedSet methods.
Summary
final SequencedSet<String> set = new LinkedHashSet<>();
set.addLast("a");
set.addLast("b");
set.addLast("c");
System.out.println(set); // [a, b, c]
System.out.println(set.reversed()); // [c, b, a]
set.addFirst("X");
set.addFirst("Y");
set.addFirst("Z");
System.out.println(set); // [Z, Y, X, a, b, c]
System.out.println(set.reversed()); // [c, b, a, X, Y, Z]
Methods
SequencedSet<E> reversed ()
final SequencedSet<String> set = new LinkedHashSet<>();
set.addLast("aaa");
set.addLast("bbb");
set.addLast("ccc");
System.out.println(set); // [aaa, bbb, ccc]
final var reversedSet = set.reversed();
System.out.println(reversedSet); // [ccc, bbb, aaa]
System.out.println(reversedSet.reversed()); // [aaa, bbb, ccc]
Methods declared in Collection
Methods declared in Iterable
Methods declared in SequencedCollection
addFirst, addLast, getFirst, getLast, removeFirst, removeLast
Please see the link below.
Methods declared in Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray
Please see the link below.
Related posts
- API Examples