Browse by Topic

Popular

Latest

Latest Java Posts

Illustration of a Java LinkedList with a peek operation highlighting the first node without removal.
Java

Java LinkedList peek() - Inspect First Element Without Removal

Learn how Java LinkedList peek() inspects the first element without removing it, including its null behavior on empty lists and how it differs from peekFirst(), peekLast(), and poll().

LinkedListpeekQueueDeque
Diagram showing the tail node being removed from a Java LinkedList with the new tail pointer highlighted.
Java

Java LinkedList removeLast: Usage and Edge Cases

java linkedlist removelast: Learn how to use LinkedList.removeLast() in Java, handle empty lists correctly, and understand when this constant-time operation fits your...

LinkedListJava CollectionsremoveLastDeque
Illustration of a Java LinkedList with the first node being removed by the removeFirst method, showing the updated head reference.
Java

Java LinkedList removeFirst() Explained

Learn how to use Java's LinkedList.removeFirst() correctly: syntax, behavior on empty lists, O(1) performance, and comparisons with pollFirst() and ArrayDeque.

JavaLinkedListCollectionsData Structures
Java LinkedList getLast method retrieving the last node in a linked list diagram.
Java

Java LinkedList getLast: Retrieve Last Element

Learn how Java's LinkedList getLast() returns the last element, why it throws on an empty list, and when peekLast() is a safer alternative. Includes code examples and performance notes.

JavaLinkedListCollectionsgetLast
Diagram showing a Java LinkedList with the getFirst() method pointing to the head node, with an empty list warning.
Java

Java LinkedList getFirst(): Usage and Pitfalls

Learn how to use Java LinkedList.getFirst(), what happens on an empty list, and how it compares with peekFirst() and other queue/deque methods.

JavaLinkedListDequegetFirst
Illustration of a Java LinkedList node being appended at the tail of a doubly linked list chain
Java

Java LinkedList addLast: Append Elements to the Tail

How to use Java's LinkedList.addLast() to append elements to the tail, including syntax, O(1) performance behavior, null edge cases, and comparisons with add() and offerLast().

LinkedListJava CollectionsDequeaddLast
Diagram showing a linked list with a new node being added at the head using addFirst method.
Java

Java LinkedList addFirst: Usage and Performance

Learn how to use Java LinkedList addFirst to prepend elements, understand its O(1) performance, and see how it compares with addLast and ArrayDeque.

JavaLinkedListaddFirstCollections
Diagram of Java LinkedList nodes with a new element being appended at the tail
Java

Java LinkedList add: Methods, Performance, and Examples

Learn how to add elements to a Java LinkedList using add(), add(int, E), addFirst, and addLast, including performance and edge cases.

Java LinkedListadd methodcollectionsdata structures
Diagram showing Java LinkedList declaration with node references and type parameter.
Java

Java LinkedList Declaration: Syntax and Common Pitfalls

Learn how to declare a LinkedList in Java correctly: syntax, type parameters, initialization options, and common pitfalls to avoid.

LinkedListJava CollectionsGenericsData Structures
Illustration of a Java LinkedList structure showing nodes connected by pointers, with a comparison to an array.
Java

Java LinkedList: Usage, Performance, and Tradeoffs

How Java LinkedList stores elements, common operation costs, and when ArrayList is a better choice.

LinkedListJava CollectionsData StructuresPerformance