List<User> sortedList = userList.stream()
.sorted(Comparator.comparingInt(User::getAge).reversed())
.collect(Collectors.toList());
sortedList.forEach(System.out::println)
In the above case if User is null it is giving NPE. How to avoid NPE here?