The switch operator java

Опубликовано: 11 Октябрь 2024
на канале: JavaLight
28
1

Unlike the if-then and if-then-else statements, the switch statement applies to a known number of possible situations. You can use simple types of byte, short, char, int. You can also use Enum and String (starting with JDK7), and special classes that are wrapper for primitive types: Character, Byte, Short, Integer.

Duplicating case values ​​is not allowed. The type of each value must be compatible with the type of expression.