Java New features


1.Record is new type of class in java that make it easy to create immutable class.
eg.public record Bank(String branch name,int branchId){
}

2.Sealed classes is to allow individual classes/interface to declare which types may used as subtype.Sealed classes have two keywords Sealed & permits.
eg public abstract sealed class Bank permits Employee , Manager {
}

3.Hidden class is to allow the runtime creation of classes that are not discoverable.This mean that they cannot be linked by other classes,nor they can be discovered by reflection.

4.Pattern matching feature is to remove lot of boilerplate code that typically come with instance of operator.

5.Java came with new string methods
likeisBlank, lines, strip, stripLeading, stripTrailing, and repeat.These methods can reduce the amount of boilerplate involved in manipulating string objects, and save us from having to import libraries.


By Shiva
Java Expert