@anonymous/

HealthyLimegreenPlan

Java

No description

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.function.*;
import static java.lang.System.out;

class Main {
  static IntSupplier makeCounter(int countBy) {
    class IntBox {
      public int n = 0;
    }
    final IntBox box = new IntBox();
    return () -> { box.n += countBy; return box.n; };
  }

  public static void main(String[] args) {
    out.println("Hello world!");
    IntSupplier counter = makeCounter(3);
    out.println(counter.getAsInt());
    out.println(counter.getAsInt());
    out.println(counter.getAsInt());
    out.println(counter.getAsInt());
  }
}