public interface Iterable<T>
- default void forEach(Consumer<super ? E> action)
- Iterator<T> iterator()
- default<T> Spliterator spliterator()
public interface Collection<E> extends Iterable<E>
Additional method signatures not in Iterable
Additional method signatures not in Iterable
- boolean add(E e)
- boolean addAll(Collection<? extends E> c)
- void clear()
- boolean contains(Object o)
- boolean containsAll(Collection<?> c)
- boolean equals(Object o)
- int hashCode()
- boolean isEmpty()
- default Stream parallelStream()
- boolean remove(Object o)
- boolean removeAll(Collection<?> c)
- default boolean removeIf(Predicate<? super E> filter)
- boolean retainAll(Collection<?> c)
- int size()
- default Stream<E> stream()
- Object[] toArray()
- <T> Object[] toArray(T[] a)
public interface Set<E> extends Collection<E>
Set's methods have exactly the same signatures as those of Collection, however, the intended methods implementation is different. Set methods' javadoc is more specific for a collection that can not have duplicate elements.
Set's methods have exactly the same signatures as those of Collection, however, the intended methods implementation is different. Set methods' javadoc is more specific for a collection that can not have duplicate elements.
public interface List<E> extends Collection<E>
Additional methods signature not in Collection
Additional methods signature not in Collection
- void add(int index, E element)
- boolean addAll(int index, Collection<? extends E> c)
- E get(int index)
- int indexOf(Object o)
- int lastIndexOf(object o)
- ListIterator<E> listIterator()
- ListIterator<E> listIterator(int index)
- E remove(int index)
- default void replaceAll(UnaryOperator<E> operator)
- E set(int index, E element)
- default void sort(Comparator<? super E> c)
- List<E> subList(int fromIndex, int toIndex)
public interface Queue<E> extends Collection<E>
Queue defined extra methods to handle head of the queue.
Queue defined extra methods to handle head of the queue.
Throws exception | Returns special value | |
Insert | add(e) |
offer(e) |
Remove | remove() |
poll() |
Examine | element() |
peek() |
- boolean add(E e)
- E element()
- boolean offer(E e)
- E remove()
- E peek()
- E poll()
public interface Deque<E> extends Queue<E>
Deque allow handling elements from either head or tail
Deque allow handling elements from either head or tail
First Element (Head) | Last Element (Tail) | |||
Throws exception | Special value | Throws exception | Special value | |
Insert | addFirst(e) |
offerFirst(e) |
addLast(e) |
offerLast(e) |
Remove | removeFirst() |
pollFirst() |
removeLast() |
pollLast() |
Examine | getFirst() |
peekFirst() |
getLast() |
peekLast() |
Queue Method |
Equivalent Deque Method |
add(e) |
addLast(e) |
offer(e) |
offerLast(e) |
remove() |
removeFirst() |
poll() |
pollFirst() |
element() |
getFirst() |
peek() |
peekFirst() |