Java 8 函数式接口,无参数,无返回值

2022-01-22 00:00:00 java-8 java java-stream

Java 8 函数式接口对于什么都不接受也不返回什么的方法是什么?

What is the Java 8 functional interface for a method that takes nothing and returns nothing?

即,等效于 C# 无参数 Actionvoid 返回类型?

I.e., the equivalent to to the C# parameterless Action with void return type?

推荐答案

如果我理解正确,你想要一个带有方法 void m() 的函数式接口.在这种情况下,您可以简单地使用 Runnable.

If I understand correctly you want a functional interface with a method void m(). In which case you can simply use a Runnable.

相关文章