Browse by Topic

Popular

Latest

Latest Java Posts

Diagram showing a HashSet with an element being removed, illustrating the remove method's effect on the set.
Java

Java HashSet remove: Removing Elements Effectively

Learn how to remove elements from a Java HashSet with the remove method, including return values, null handling, iteration removal, bulk operations, and performance.

HashSetJava CollectionsSet APIElement Removal
Diagram of a Java HashSet add operation showing a new element being inserted and a duplicate being rejected.
Java

Java HashSet add: Behavior, Return Value, and Duplicate Handling

Understanding HashSet.add() in Java: its return value, duplicate detection, performance characteristics, and practical usage patterns.

JavaHashSetCollectionsData Structures
A stylized illustration of a Java HashSet declaration showing angle brackets and a set of unique elements
Java

Java HashSet Declaration: Syntax and Initialization

Learn how to declare and initialize a HashSet in Java, including generic syntax, common initialization patterns, and practical tradeoffs when choosing a Set implementation.

HashSetJava CollectionsType ParametersJava Syntax
Diagram showing how Java HashSet stores unique elements in hash buckets with a comparison to ordered set variants.
Java

Java HashSet: Usage, Behavior, and Performance

Understand Java HashSet behavior: uniqueness, hashCode and equals, iteration order, performance tradeoffs, and when to choose it over other Set types.

HashSetJava CollectionsData StructuresJava Performance
Diagram showing a List interface reference pointing to an ArrayList object, illustrating the difference between interface and implementation.
Java

Java List vs ArrayList: Choosing the Right Reference Type

Understand the practical difference between the List interface and the ArrayList class in Java, and learn which reference type to use in your code.

JavaArrayListList InterfaceJava Collections
A Java code snippet showing List.of creating an immutable list, with a lock icon representing immutability.
Java

Java Immutable List: Creation and Practical Use

Java immutable list: Learn how to create one with List.of, Collections.unmodifiableList, and stream collectors. Understand null handling, performance, and when to use each approach.

immutable-listjava-collectionslist-ofunmodifiable-list
A Java code snippet showing List.copyOf creating an immutable list from a mutable source collection.
Java

Creating Immutable Lists with Java List.copyOf()

Learn how Java's List.copyOf() creates immutable lists from existing collections, handles nulls, and compares with other list-creation approaches.

JavaImmutable CollectionsList.copyOfJava Collections
A visual comparison of Java list creation methods, showing immutable and mutable list representations with arrows indicating mutability.
Java

Java List of: Creating and Initializing Lists

java list of: Learn how to create lists in Java using List.of, Arrays.asList, ArrayList, and streams, with key differences in mutability and performance.

List.ofArrays.asListArrayListJava Streams
Illustration of sorting a Java list with comparator and comparable concepts.
Java

Java List Sort: Using Comparator and Comparable

Learn how to sort a Java List with Collections.sort, List.sort, Comparator, and Comparable, including reverse order and null handling.

javasortingcomparatorcomparable
Illustration of a Java list with indexed elements where a magnifying glass highlights the matching element found by indexOf.
Java

Java List indexOf: Syntax, Behavior, and Performance

How Java List.indexOf works: equals-based matching, the -1 return value, null handling, and performance tradeoffs between ArrayList and LinkedList.

JavaListArrayListindexOf