Java 8 | LongSupplier Interface with Examples Last Updated : 10 Oct, 2018 Comments Improve Suggest changes Like Article Like Report The LongSupplier Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which does not take in any argument but produces a long value. The lambda expression assigned to an object of LongSupplier type is used to define its getAsLong() which eventually applies the given operation on its argument. It is similar to using an object of type Supplier<Long> Functions in LongSupplier Interface The LongSupplier interface consists of the only one function: 1. getAsLong() This method does not take in any value but produces a long-valued result. Syntax: long getAsLong() Return Value: This method returns a long value. Below is the code to illustrate getAsLong() method: Program: Java // Java program to illustrate // getAsLong() method import java.util.function.LongSupplier; public class GFG { public static void main(String args[]) { // Create a LongSupplier instance LongSupplier sup = () -> (int)(Math.random() * 10); // Get the long value // Using getAsLong() method System.out.println(sup.getAsLong()); } } Output: 6 Comment More infoAdvertise with us Next Article Java 8 | LongSupplier Interface with Examples P psil123 Follow Improve Article Tags : Misc Java Java-Library Java - util package Java 8 +1 More Practice Tags : JavaMisc Similar Reads Supplier Interface in Java with Examples The Supplier Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which does not take in any argument but produces a value of type T. Hence this functional interface takes in only one gener 1 min read Java 8 | ObjLongConsumer Interface with Example The ObjLongConsumer Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in two arguments and produces a result. However these kind of functions don't return any value. Hence th 2 min read LongConsumer Interface in Java with Examples The LongConsumer Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in one long-valued argument but does not return any value. The lambda expression assigned to an object of L 3 min read Java 8 | IntSupplier Interface with Examples The IntSupplier Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which does not take any argument but produces an int value. The lambda expression assigned to an object of IntSupplier t 1 min read Java 8 | ObjDoubleConsumer Interface with Example The ObjDoubleConsumer Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in two arguments and produces a result. However these kind of functions don't return any value. Hence 2 min read Java Native Interface with Example In the Programming World, it is often seen in the comparison of Java vs C/C++. Although the comparison doesn't make any such sense, as both the languages have their Pros and Cons, but what if we can use multiple languages in a single Program?In this article, we will learn How to use JNI(Java Native 4 min read LongFunction Interface in Java with Examples The LongFunction Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in a long-valued argument and produces a result of type R. This functional interface takes in only one gene 1 min read ToLongFunction Interface in Java with Examples The ToLongFunction Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in an argument of type T and produces a long-valued result. This functional interface takes in only one g 1 min read ToLongBiFunction Interface in Java with Examples The ToLongBiFunction Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in two arguments of type T and U and produces an long-valued result. This functional interface takes in 2 min read LongToIntFunction Interface in Java with Examples The LongToIntFunction Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in a long-valued argument and gives an int-valued result. The lambda expression assigned to an object 1 min read Like