Oℕ
Size: a a a
Oℕ
AK
Oℕ
Oℕ
Oℕ
Oℕ
AK
KS
Oℕ
Oℕ
KS
Oℕ
KS
Oℕ
Oℕ
Oℕ
EK
EK
3. Dealing with null
null, и теперь
switch(null)не будет выбрасывать
NullPointerException, если будет добавлена ветка
case null -> ….
static void test(Object o) {
switch (o) {
case null -> System.out.println("null!");
case String s -> System.out.println("String");
default -> System.out.println("Something else");
}
}
final var trueOptional = …;
switch(trueOptional) {
case Some -> …
case None -> …
case null -> …
}