Tag: java16

  • Java 16 features every Java developer should know

    Java 16 features every Java developer should know

    Java 16 just released. Though a lot of new features were introduced only six of them need to be understood by day to day java developers. Here are those features: Records Pattern matching for instanceof Sealed classes (Second preview) jpackage packaging tool Stream.toList() method Day Period support added to java.time Formats 1.Records: If you want…

  • How, Why and When to use Stream.toList() method in Java?

    Java 16 introduced a new method toList() to Stream interface. How is this going to help Java Developers? Let’s see it through an example. Let us take the use case where you want to iterate through a stream of objects, filter it based on certain criteria and save the results in a list. Traditionally you…

  • How to use Pattern Matching for instanceof operator in Java?

    Let’s say you have a generic method which accepts any object as a parameter. Based on the type of the object , the method performs custom operations. Traditionally to implement this you need to do the following steps: Check the passed parameter using instanceof operator for the specific type If it matches , cast the…