Java Stream flat map each letter in String Stream

Description

Java Stream flat map each letter in String Stream


import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {
    Stream.of("XML", "Java",  "CSS","Javascript","SQL", "C++")
        .flatMap(name ->  IntStream.range(0, name.length()).mapToObj(name::charAt))
        .forEach(System.out::println);
  }//from   w ww.j  a v a 2 s.co m
}



PreviousNext

Related