The Definitive Guide To Java 15

The Definitive Guide To Java 15

Java 14: Pattern Matching for instanceof (JEP 305), Helpful NullPointerExceptions (JEP 358), Records (JEP 359), Switch Expressions (JEP 361),

Java is nowadays one of the worldwide spreadest programming languages with its Java SE 8 released on March 18, 2014 and that counts about 60% of usage in the main applications.

Java 14, and then Java 15, have been released respectively on March 17 and September 15 2020 increasing features for developers.

Let’s have an overview of the main JEP (Java Enhancement Proposal) for each release.

Java 14: Pattern Matching for instanceof(JEP 305), Helpful NullPointerExceptions (JEP 358), Records (JEP 359), Switch Expressions (JEP 361), Text Blocks (JEP 368)

*Java 15: *Sealed Classes or Interfaces(JEP 360)

Java 14

Pattern Matching for instanceof

Each Java programmer should know the older syntax used to define an instanceof block. It foresaw three main steps: test, declaration of new variable and a conversion (casting obj to String)

if (obj instanceof String) {
    String s = (String) obj;
    // use s
}

The istanceof operator is now extended to take a type test pattern instead of just a type. In the example below, _YourClass y _is the type test pattern.

public class YourClass {

        private int value;

        public YourClass(int value) {
            this.value = value;
        }

        public int multiply(Object o) {
            if (o instanceof YourClass y)
                return this.value * y.value
        }

        // other methods ...

        @Override
        public boolean equals(Object o) {
            return (o instanceof YourClass y)
                && value == y.value;
        }

    }

As you can notice, the new instanceof operator allows you to test, declare and cast variables in a single step. Obviously, you can use the newly declared variable right away!

This kind of syntax simplifies the implementation of methods too. Take a closer look at the equals() and multiply() methods in the snippet above.

programming coding training spring java

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install OpenJDK 11 on CentOS 8

What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).

3 Coding Best Practices I learned from Spring Framework in Java

Spring is much more than just another DI and IOC framework and you can learn how to write better code using Spring.

Spring | Spring JDBC Tutorial | Java Spring Tutorial Spring Training

Spring | Spring JDBC Tutorial | Java Spring Tutorial Spring Training . Spring Framework Certification Training This post Spring JDBC Tutorial video will help you

Top 10 Pluralsight courses learn Spring Framework for Java developers

Top 10 Pluralsight courses learn Spring Framework for Java developers. Best Pluralsight courses to learn Spring Framework, Spring Boot, Spring MVC, Spring Security and Spring Cloud for Java developers.

Spring Live | Introduction to Spring Framework | Java Spring Tutorial | Spring Training

Spring Live , Introduction to Spring Framework, Java Spring Tutorial ,Spring Training .Spring Framework Certification Training "Introduction to Spring Framework"