Java Lambda - IntSupplier getAsInt example








IntSupplier getAsInt gets a result from the functional interface.

Syntax

getAsInt has the following syntax.

int getAsInt()

Example

The following example shows how to use getAsInt.

import java.util.function.IntSupplier;
//from www.  j a v  a2  s  .com
public class Main {

  public static void main(String[] args) {
    IntSupplier i = ()-> Integer.MAX_VALUE;
    
    System.out.println(i.getAsInt());

  }
}

The code above generates the following result.