Skip to main content

Java

Java BitSet Explained (with Practical Examples)

When developing applications, there are situations where we need to represent and manipulate large collections of binary values – typically true or false. Storing these values in a conventional data structure like a boolean[] or a HashSet<Integer> can be inefficient in terms of memory and speed. Java provides the BitSet class in the java.util package to address this problem. BitSet represents a sequence of bits that can grow dynamically and provides built-in methods for bit-level manipulation. In this article, we will cover: Introduction to BitSet Internal representation and advantages Common operations Basic usage example Real-world example: Attendance tracking Bitwise operations (AND, OR, XOR, ANDNOT) Performance comparison with boolean[] and HashSet Conclusion

Java Interview Preparation Guide

A categorized Java interview prep guide covering core Java, collections, concurrency, Streams/Optional, and Spring basics, with annotated code, comparison tables, and notes on why each topic trips candidates up.

Overview of New Features in Java 19

Java 19 has just been released — September 20, 2022 — as a short-term support release on the six-month cadence the Java platform moved to starting with Java 9. It is not an LTS release, but that does not make it uninteresting: Java 19 ships 7 JEPs, several of them highly anticipated by the Java community. Virtual Threads, in particular, represent one of the most significant changes to the Java concurrency model in years. The headline features span concurrency, pattern matching, native interop, and platform reach. Three features arrive as preview (complete but seeking feedback), one as an incubator module (early-stage API), and the rest are fully stable additions. Because several require flags to enable, we will also cover exactly how to turn them on — both on the command line and in Maven. This article walks through each major Java 19 feature with code examples and explains the preview and incubator status so you know what you can try today and what to expect in future releases.

Apache Commons Collection – MultiValuedMap

Apache Commons Collections MultiValuedMap compared against Guava Multimap and a vanilla nested Map of Lists, with a realistic form-validation-errors use case, annotated code, sample output, and FAQs.

Quick Sort in Java: Lomuto vs Hoare Partition, Dry Run and Complexity

Quick Sort in Java with both the Lomuto and Hoare partition, traced step by step on the same array, then measured: comparisons, swaps and recursion depth on random, sorted, reverse-sorted, all-equal and few-distinct-key input. Covers random pivots, three-way partitioning, recursing into the smaller side, what Arrays.sort really does, and two bugs found in the 2015 versions of this post.