本文主要是介绍Java Supplier 供给型接口,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
源码展示
package java.util.function;
/**
* Represents a supplier of results.
*
* There is no requirement that a new or distinct result be returned each
* time the supplier is invoked.
*/
@FunctionalInterface
public interface Supplier<T> {
/**
* Gets a result.
*/
T get();
}
示例
import java.util.function.Supplier;
public class Test {
public static void main(String args[]) {
Supplier<String > s = ()->{
return "费哥哥,我爱你哦!";
};
System.out.println( s.get());
}
}
这篇关于Java Supplier 供给型接口的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!