Use Optional to represent nullable values with a more functional approach, reducing NullPointerException.
Source Code
Optional optional = Optional.ofNullable(null);
optional.ifPresent(System.out::println); // No output
System.out.println(optional.orElse("Default Value")); // Outputs: Default Value