java stream filter
List<String> result = lines.stream()
.filter(line -> "theLineIWant".equals(line))
.collect(Collectors.toList());
java stream filter
List<String> result = lines.stream()
.filter(line -> "theLineIWant".equals(line))
.collect(Collectors.toList());
java stream().filter()
NowJava8.java
package com.ricky.java8;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class NowJava8 {
public static void main(String[] args) {
List<String> lines = Arrays.asList("spring", "node", "ricky");
List<String> result = lines.stream() // convert list to stream
.filter(line -> !"ricky".equals(line)) // we dont like ricky
.collect(Collectors.toList()); // collect the output and convert streams to a List
result.forEach(System.out::println); //output : spring, node
}
}12345678910111213141516171819202122
java stream and filter
items.stream()
.filter(s->s.contains("B"))
.forEach(System.out::println);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us