8 Primitive Types in Patterns, instanceof, and switch

You can use primitive types in all pattern contexts, and the instanceof operator and switch statements and expressions work with all primitive types. See the following sections for more information:

Note:

Using primitive types in patterns, instanceof, and switch is a preview feature. This is a preview feature. A preview feature is a feature whose design, specification, and implementation are complete, but is not permanent. A preview feature may exist in a different form or not at all in future Java SE releases. To compile and run code that contains preview features, you must specify additional command-line options. See Preview Language and VM Features.

See JEP 530: Primitive Types in Patterns, instanceof, and switch (Fourth Preview) for additional information.