Browse by Topic

Popular

Latest

Latest Java Posts

Illustration of Java Iterator.remove() removing an element from a collection during iteration.
Java

Java Iterator remove: Safe Element Removal During Iteration

Learn how to use Java Iterator.remove() to safely delete elements from collections during iteration, avoid ConcurrentModificationException, and choose between removeIf and explicit iterators.

Java CollectionsIteratorConcurrentModificationExceptionremoveIf
A diagram showing a Java iterator cursor moving through a collection with hasNext and next checkpoints
Java

Java Iterator hasNext and next: How They Work

Learn how Java's Iterator hasNext() and next() methods work together for safe collection traversal, including common mistakes and when to use an explicit iterator.

Java IteratorhasNextnextCollection Traversal
Illustration of Java Iterator interface traversing a collection with fail-fast behavior.
Java

Java Iterator Interface: Usage and Implementation

Understand the Java Iterator interface: its methods, how to implement custom iterators, and common pitfalls like fail-fast behavior.

JavaIteratorCollectionIterable
Diagram of Java Iterator traversing a collection with next and hasNext indicators
Java

Java Iterator: Usage, Implementation, and Common Pitfalls

Understand the Java Iterator interface: its methods, how for-each uses it, safe removal, custom iterators, and fail-fast behavior.

JavaIteratorCollectionIterable
Diagram comparing Java Stack and ArrayDeque implementations for stack operations.
Java

Java Stack vs ArrayDeque: Choosing the Right Stack Implementation

Compare Java's legacy Stack class with ArrayDeque for LIFO stack operations: synchronization, null handling, performance, and when to choose each.

JavaStackArrayDequeCollections
A visual comparison of Java's Stack class and Deque interface showing LIFO push and pop operations with ArrayDeque as the recommended replacement.
Java

Java Stack vs Deque: Choosing the Right LIFO Structure

Compare Java's legacy Stack class with the Deque interface for LIFO operations, including API differences, performance, and migration guidance.

JavaDequeStackLIFO
A Java Stack illustration with an empty stack and a checkmark indicating isEmpty() returns true.
Java

Java Stack isEmpty() Method Explained

Learn how to use Java Stack isEmpty() to check for empty stacks, understand its behavior, compare it with alternatives, and avoid common mistakes.

JavaStackisEmptyCollections
Diagram of a Java Stack showing push adding an element on top, pop removing the top element, and peek inspecting the top element without removal.
Java

Java Stack push, pop, and peek: Core LIFO Operations

Learn how push, pop, and peek work in Java's Stack class, including empty-stack behavior, thread-safety tradeoffs, and when ArrayDeque is a better choice.

Java StackLIFOArrayDequeCollections
Illustration showing a stack data structure with elements pushed and popped in LIFO order, highlighting the Java Stack class.
Java

Java Stack Class: Usage, Tradeoffs, and Examples

Understand the java.util.Stack class, its LIFO mechanics, synchronization overhead, and when ArrayDeque is a better choice for performance-sensitive code.

StackLast-In-First-OutJava CollectionsDeque
A stylized stack data structure with LIFO operations and Java-related visual elements.
Java

Java Stack: Usage, Methods & Concurrency

java stack: Understand Java's Stack class: LIFO behavior, methods, synchronization legacy, and why ArrayDeque is often the preferred replacement.

Java StackStack ClassDequeConcurrency