Last active
May 1, 2019 07:17
-
-
Save kunals201/ef6af6dee535c7a13e1c350ca9ac355c to your computer and use it in GitHub Desktop.
Use case of collectionUtils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.knoldus; | |
import org.apache.commons.collections4.CollectionUtils; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class LambdaEx { | |
public static void main(String[] args) { | |
ArrayList<String> list = null; | |
final List<String> modifiedCollection = CollectionUtils.emptyIfNull(list) | |
.stream() | |
.map(elem -> elem + " ") | |
.collect(Collectors.toList()); | |
CollectionUtils.emptyIfNull(modifiedCollection).forEach(System.out::println); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment