In the Part 1, we discussed about improved enum constants as case labels in Java 21. In this article, we will focus on patterns in switch labels. In general, the value of the selector expression is compared with the case label by an equality test. But this mechanism changes when patterns come at the case label. In this case, label is selected based on the result of pattern … [Read more...] about Pattern Matching for Switch in Java 21 – Part 2
JDK 21
The Z Garbage Collector (ZGC) – Colored Pointers, Load Barriers, and Store Barriers
In the previous article, we have seen the fundamental difference between the non-generational ZGC and the generational ZGC. In this article, we will briefly cover the idea behind colored pointers, load barriers, and store barriers. ZGC (both non-generational and generational) reads and modifies the object graph in heap memory concurrently with the application … [Read more...] about The Z Garbage Collector (ZGC) – Colored Pointers, Load Barriers, and Store Barriers
Pattern Matching for Switch in Java 21 – Part 1
We will start this article with the below diagram. In both cases (switch statement and switch expression), we use the keyword switch and terms selector expression and switch block. But there are a few important differences. One difference is that switch expressions cannot have empty switch blocks, unlike switch statements. The below examples will … [Read more...] about Pattern Matching for Switch in Java 21 – Part 1
Record Patterns in Java 21
We will start this article with record classes. Record Classes Consider the below Java class: The above MaxMin class basically a data aggregate that carrying two data values: max and min. This class is serving as a data carrier. Instead of writing one public constructor with all the data fields, a public accessor method for each data field, equals method, hashCode … [Read more...] about Record Patterns in Java 21
Sequenced Collections in Java 21
In this article, I will provide a brief and meaningful overview of sequenced collections in Java 21. What Is A Sequenced Collection? According to JEP 431, a sequenced collection is a Collection whose elements have a defined encounter order. A sequenced collection has first and last elements. Every element between the first and last one has successors … [Read more...] about Sequenced Collections in Java 21