Browse by Topic

Popular

Latest

Latest Java Posts

Illustration of a Java ArrayList containing multiple product objects, with type safety and sorting concepts.
Java

Java ArrayList of Objects: How to Use It

Learn how to create and work with an ArrayList of objects in Java, including type-safe declarations, iteration, sorting, and common pitfalls.

ArrayListGenericsJava CollectionsObject-Oriented Java
Diagram comparing an ArrayList's contiguous array storage with a LinkedList's node-based chain, illustrating direct access versus sequential traversal.
Java

Java ArrayList vs LinkedList: Choosing the Right List

Compare Java's ArrayList and LinkedList: internal storage, access cost, memory overhead, and concrete criteria for choosing the right List implementation.

ArrayListLinkedListJava CollectionsData Structures
Illustration comparing a fixed-size array and a dynamically growing ArrayList, with a lock on the array and a plus icon on the list.
Java

Java ArrayList vs Array: Key Differences

Compare Java arrays and ArrayList on syntax, type safety, performance, and use cases, with practical guidance for choosing the right structure.

JavaArrayListArraysCollections
Diagram showing an ArrayList as a container with filled slots for size and empty slots for spare capacity.
Java

Java ArrayList Capacity: Size vs Capacity

Understand how ArrayList capacity works, how resizing affects performance, and when to set initial capacity or call ensureCapacity and trimToSize.

ArrayListJava CollectionsMemory ManagementPerformance
Illustration of removing duplicate elements from a Java ArrayList, showing a sequence of colored cards with repeated colors being removed and only unique cards remaining
Java

Remove Duplicates from ArrayList in Java

Learn how to remove duplicates from an ArrayList in Java using LinkedHashSet, HashSet, and Stream.distinct(), with tradeoffs for order, performance, and custom objects.

javaarraylistcollectionsdeduplication
Illustration of converting a Java array to an ArrayList with arrows showing transformation.
Java

Java Array to ArrayList: Conversion Methods and Tradeoffs

java array to arraylist: Learn how to convert a Java array to an ArrayList using Arrays.asList, List.of, and manual loops, including mutability and performance tradeoffs.

JavaArrayListArraysCollections
Illustration of a Java ArrayList converting into a typed array, showing the toArray transformation from linked boxes to a contiguous row.
Java

Java ArrayList to Array: Safe Type Conversion

java arraylist to array: Convert a Java ArrayList to an array safely. Learn the toArray() overloads, type erasure pitfalls, and the zero-length array idiom.

ArrayListtoArrayType ConversionJava Collections
Illustration of an ArrayList being reversed in place, with elements swapping positions from both ends toward the center.
Java

How to Reverse an ArrayList in Java

Learn how to reverse a Java ArrayList in place or as a copy using Collections.reverse(), two-pointer swaps, backward iteration, and ListIterator traversal.

JavaArrayListCollectionsIn-place Reversal
Illustration of an ArrayList being sorted with a comparator, showing ordered elements and a sort arrow.
Java

Java ArrayList Sort: Collections.sort() and Comparator

Learn how to sort an ArrayList in Java using Collections.sort(), Comparators, reverse order, and Stream.sorted, with practical examples and edge cases.

JavaArrayListCollections.sortComparator
Illustration of a Java ArrayList iterator traversing a list while safely removing an element.
Java

Java ArrayList Iterator: Usage and Common Pitfalls

Learn how to use the Java ArrayList iterator, remove elements safely during iteration, and avoid ConcurrentModificationException.

JavaArrayListIteratorCollections