Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.function.IntSupplier;
import java.util.stream.IntStream;

public class Main {

    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;
            }
        };
        IntStream.generate(fib).limit(10).forEach(System.out::println);
    }

}