How do I replace the Supplier
code here with lambda expression
IntStream inStream = Stream.generate(new Supplier<Integer>() {
int x= 1;
@Override
public Integer get() {
return x++ ;
}
}).limit(10).mapToInt(t -> t.intValue());
inStream.forEach(System.out::println);
The output of above piece of code is:
1
2
3
4
5
6
7
8
9
10