I am learning flat map and want to print infinite sequence of integers.
However, when I try to compile the program it is failing at System.out.println:
public class Test{
public static void main(String[] args) {
Stream.of("").flatMap(x -> Stream.iterate(1, i -> i + 1)).forEach(System.out.println);
}
}
Can some one help me on this and let me know how can I do this and if possible please check my code for printing infinite sequence of integers for problems.