Search code examples
javalambdajava-8functional-interface

Java function signature for (() -> {})


What's a valid function signature for funSig?

funSig(() -> System.out.println());

Solution

  • A Runnable would work,

    It matches a void return and no params.

    Runnable runnable = () -> System.out.println();
    

    And obviously it doesn't need to be Runnable, any Functional Interface that matches the signature will do.