Java Stream filter, sort, for each to display result

Description

Java Stream filter, sort, for each to display result

import java.util.Arrays;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    List<Integer> numbers = Arrays.asList(1,2,3,4,5,6,7,8,9,0);
    numbers.stream()//from  www .j a va2  s.  c o  m
        .filter(n -> n % 2  == 1)
        .sorted()
        .forEach(System.out::println);
  }
}



PreviousNext

Related