Consider following interface.



interface Runnable{
    public void run();
}

Which of the following will create instance of Runnable type?

A.

Runnable run = () -> {System.out.println("Run");};

B.

Runnable run = () -> System.out.println("Run");

C.

Runnable run = () > System.out.println("Run");

D.

Runnable run = > System.out.println("Run");

E. None of the above.

題解

Java 8導入了Lambda語法,可以參考這篇文章來學習:

https://magiclen.org/java-8-lambda/