Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Remove null from Java List

// This will change the existing list
List<String> list = Arrays.asList("A", null, "B", null);
list.removeIf(Objects::isNull);

// This will return a new list without the null
List<String> list = Arrays.asList("A", null, "B", null);
List<String> newList = list.stream()
  				.filter(Objects::nonNull)
  				.collect(Collectors.toList());
Source by www.javacodegeeks.com #
 
PREVIOUS NEXT
Tagged: #Remove #null #Java #List
ADD COMMENT
Topic
Name
6+9 =