Skip to content

Commit 301ceeb

Browse files
committed
Add Java SE 21 features to README.
1 parent f8f3049 commit 301ceeb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33

44
- First of all, let's start with some of the updates and advancements in Java library (aptly called Java API).
55

6+
7+
## What's available in Java 21 API
8+
New features available in Java 21 which we missed in Java 17 and earlier versions. Features, which are most notable and stand as the best candidates for frequent use, are listed below:
9+
- Usage of `record` types in conditionals. Very useful with `if(reference instance Type)` tests.
10+
<pre>if(publicParameter instanceof SpecificType) {}</pre>
11+
- labels for `switch` cases. These are very similar to `instanceof` checks.
12+
<pre>
13+
case TierOne test -> future = test.callActionOne();
14+
case TierTwo test -> future = test.callActionTwo();
15+
</pre>
16+
- String literals (a preview feature) to build parameterized text strings. These are similar to string literals / template strings of modern JavaScript and f-strings of python. The template processor `STR` is automatically imported and is available to use without any explicit import or declaration. More template processors include `RAW` and `FMT`. Remember `"fmt"` of Go (Golang)?
17+
<pre>String vmUserName = localSystem.retrieveUserName();
18+
String helloVitrualWorld = STR."Hola \{vmUserName}";</pre>
19+
- One major pathchanger about Java Collection Framework is: the introduction of "sequenced collections": `SequencedCollection`, `SequencedSet` and `SequencedMap`.
20+
<pre>
21+
public interface SequencedCollection<E> extends Collection<E> // since 21
22+
public interface SequencedMap<K, V> extends Map<K, V> // since 21
23+
public interface SequencedSet<E> extends SequencedCollection<E>, Set<E> // since 21
24+
</pre>
25+
- My favorite as it is about security and encryption: Key Encapsulation Mechanism (KEP) to secure symmetric keys.
26+
- TODO: Add screenshots [Due 21-Jun-2024]
27+
628
## What's available in Java 17 API
729
New features available in Java 17 over Java 14. Features, which are most notable and stand as the best candidates for frequent use, are listed below:
830
- restore always-Strict floating-point semantics: It ensures same results of floating-point calculations on every platform.

0 commit comments

Comments
 (0)