Share code snippets.

RemoveNullElementsFromListJava8

Created 2 years ago by anonymous
Java 8 - Remove null elements from List
public static void main(String[] args) {

		List<String> listwithnulls = new ArrayList<String>();
		listwithnulls.add("apple");
		listwithnulls.add(null);
		listwithnulls.add("mango");
		listwithnulls.add(null);
		listwithnulls.add("banana");
		System.out.println("Let's now Filter Null Elements - ");
		listwithnulls.stream().filter(value -> value != null).forEach(System.out::println);

	}