package algus; import java.util.function.Supplier; import java.util.stream.Stream; public class PikkVoog1 { static class PaarisarvudeLooja implements Supplier{ int loendur=0; public PaarisarvudeLooja(){ this(0); } public PaarisarvudeLooja(int algus){ loendur=algus/2; } @Override public Integer get() { return 2*loendur++; } } public static void main(String[] args) { Stream.generate(() -> 7).limit(3).forEach(System.out::println); Stream.generate(new PaarisarvudeLooja()).limit(3).forEach(System.out::println); Stream.generate(new PaarisarvudeLooja(100)).limit(3).forEach(System.out::println); Stream.iterate(0, a -> a+2).limit(4).forEach(System.out::println); } }