S
Size: a a a
S
AL
S
D
D
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 -> …
}
AL
S
S
S
S
AL
AL
AL
D
AL
AD