diff --git a/src/main/java/com/insightfullogic/java8/answers/chapter3/StringExercises.java b/src/main/java/com/insightfullogic/java8/answers/chapter3/StringExercises.java index 336b9b9f..80d5a340 100644 --- a/src/main/java/com/insightfullogic/java8/answers/chapter3/StringExercises.java +++ b/src/main/java/com/insightfullogic/java8/answers/chapter3/StringExercises.java @@ -2,12 +2,14 @@ import java.util.Comparator; import java.util.List; +import java.util.Objects; import java.util.Optional; public class StringExercises { // Question 6 public static int countLowercaseLetters(String string) { + if (Objects.isNull(string)) return 0; return (int) string.chars() .filter(Character::isLowerCase) .count();