Text Block, Sealed Classes, ZGC & Shenandoah Garbage Collector, and many more!
By following its 6 — month release cycle, Java 15 becomes the 2nd release of 2020. Every 3-year LTS version will be released, and the next LTS will be Java 17 in 2021. And you can see that release was consistent with the planned schedule.
1: Text Blocks
// Without Text Block
String jsnWithoutTxtBlck = "{\n"+
" \"a\": "+ "\"b\""+"\n"+
"}";
System.out.println(jsnWithoutTxtBlck);
//Text Block Example
String jsn = """
{
"a":"b"
}
""";
System.out.println(jsn);
//Text Block Example With Formatted
String jsnFormatted = """
{
"a":"%s"
}
""".formatted("b");
System.out.println(jsnFormatted);
2: Helpful Null Pointer Exception Message
— XX:ShowCodeDetailsInExceptionMessages.
1: Sealed Classes
int getCenter(Shape shape) {
return switch (shape) {
case Circle c -> ... c.center() ...
case Rectangle r -> ... r.length() ...
case Square s -> ... s.side() ...
};
}
#java #programming #developer