List of usage examples for java.util.function IntSupplier IntSupplier
IntSupplier
From source file:Main.java
public static void main(String[] args) { IntStream.generate(new IntSupplier() { public int getAsInt() { return 2; }// w ww. j ava 2 s. c o m }).limit(5).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { IntSupplier fib = new IntSupplier() { private int previous = 0; private int current = 1; public int getAsInt() { int nextValue = this.previous + this.current; this.previous = this.current; this.current = nextValue; return this.previous; }/*w w w.j ava 2 s . c o m*/ }; IntStream.generate(fib).limit(10).forEach(System.out::println); }