Equivalent for Python's lambda functions in Java?

前端 未结 7 1481
小蘑菇
小蘑菇 2021-02-05 06:41

Can someone please tell me if there is an equivalent for Python\'s lambda functions in Java?

7条回答
  •  你的背包
    2021-02-05 07:00

    Yes,

    Lambda expressions are introduced in java from java8.

    Basic syntax for lambda expressions are:

    (parameters)->
    {
      statements;
    }
    

    Example

    (String s)->
    {
    System.out.println(s);
    }
    

    Check this link:

    http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html

提交回复
热议问题