Created
November 24, 2022 12:46
-
-
Save alexandreroman/15d4c4166aa338819ecd310ed863934e to your computer and use it in GitHub Desktop.
Lambda with java.util.List
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 sandbox; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class Main { | |
public static void main(String[] args) { | |
var strList = List.of("Hello", "world", "my", "name", "is", "Duke"); | |
System.out.println("List: " + strList); | |
var newStrList = strList.stream().filter(s -> s.length() > 4).collect(Collectors.toUnmodifiableList()); | |
System.out.println("New list: " + newStrList); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment