Java> = 8中没有args且没有返回类型(void)的“函数”

发布于 2021-01-31 15:23:02

JDK中是否有一个标准功能接口,该接口什么都不做,什么也不返回?我找不到一个。类似于以下内容:

@FunctionalInterface
interface Action {
  void execute();
}
关注者
0
被浏览
56
1 个回答
  • 面试哥
    面试哥 2021-01-31
    为面试而生,有面试问题,就找面试哥。

    那么Runnable呢:

    @FunctionalInterface
    public interface Runnable {
        /**
         * When an object implementing interface <code>Runnable</code> is used
         * to create a thread, starting the thread causes the object's
         * <code>run</code> method to be called in that separately executing
         * thread.
         * <p>
         * The general contract of the method <code>run</code> is that it may
         * take any action whatsoever.
         *
         * @see     java.lang.Thread#run()
         */
        public abstract void run();
    }
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看