Skip to content

itsvikramcollab/test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Java 17 examples: Sealed classes and Pattern Matching for switch

Files created/updated:

  • Abc.java — demonstrates sealed types and instanceof pattern matching (no preview needed).
  • PatternSwitchExample.java — demonstrates pattern matching for switch (preview in Java 17).

Compile & run

  1. Sealed classes example (no preview flags required):
javac Abc.java
java Abc
  1. Pattern matching for switch (preview feature in Java 17): compile and run with preview enabled:
javac --enable-preview --release 17 PatternSwitchExample.java
java --enable-preview PatternSwitchExample

Notes:

  • PatternSwitchExample uses a preview language feature in Java 17; the --enable-preview flag is required at both compile and run time.
  • If your javac/java targets a newer JVM, adjust the --release/--source flags accordingly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages