Pattern Matching for Switch in Java 21 Preview

Pattern Matching for Switch in Java 21

With Buddhini Samarakkody Liked by 42 users
Duration: 1h Skill level: Intermediate Released: 6/20/2025

Course details

Description

What is this course about?

The course is designed for intermediate Java developers looking to upskill and grow their career. Join instructor Buddhini Samarakkody as she covers the essentials of the pattern matching feature for switch statements and expressions which was introduced in Java 21. Learn how patterns can be used in case labels of a switch statement or expression, using guarded patterns to further test if a value matches a pattern, the use of Java Records in switch, along with pattern matching. Along the way, Buddhini outlines the use of the null case label to avoid NullPointerExceptions in switch statements or expressions. By the end of this course, you’ll be equipped with the skills you need to write more readable, more concise, more powerful code.

This course includes Code Challenges powered by CoderPad. Code Challenges are interactive coding exercises with real-time feedback, so you can get hands-on coding practice alongside the course content to advance your programming skills.

Objectives

What will I be able to do by the end of this course?

  • Identify the need for pattern matching for switch.
  • Write switch statements or expressions containing patterns in case labels.
  • Demonstrate the use of null case labels to prevent NullPointerExceptions.
  • Apply guarded patterns in case labels to test if a value matches a pattern.
  • Utilize switch statements and expressions with Java Records for efficient pattern matching.

Audience

Who is this course for?

  • Intermediate Java developers
  • Software developers familiar with Java
  • Programmers interested in Java 21 updates

Prerequisites

What do I need to know before taking this course?

  • Basic understanding of Java programming
  • Familiarity with Java switch statements
  • Experience in writing Java code

Skills you’ll gain

Earn a sharable certificate

Share what you’ve learned, and be a standout professional in your desired industry with a certificate showcasing your knowledge gained from the course.

Sample certificate

Certificate of Completion

  • Showcase on your LinkedIn profile under “Licenses and Certificate” section

  • Download or print out as PDF to share with others

  • Share as image online to demonstrate your skill

Meet the instructor

Learner reviews

5 out of 5

1 rating
  • 5 star
    Current value: 1 100%
  • 4 star
    Current value: 0 0%
  • 3 star
    Current value: 0 0%
  • 2 star
    Current value: 0 0%
  • 1 star
    Current value: 0 0%

Contents

What’s included

  • Practice while you learn 1 exercise file
  • Test your knowledge 3 quizzes
  • Learn on the go Access on tablet and phone

Similar courses

Download courses

Use your iOS or Android LinkedIn Learning app, and watch courses on your mobile device without an internet connection.