Null safety Java

PHOTO EMBED

Mon Apr 26 2021 21:07:29 GMT+0000 (UTC)

Saved by @GoodRequest.

Person person = new Person(null, 21);
try {
    System.out.println(person.getName().charAt(0));
} catch (NullPointerException e) {
    System.out.println("No name");
}
content_copyCOPY