Java 8 lambda expression and first-class values

后端 未结 5 1527
忘了有多久
忘了有多久 2020-11-27 16:20

Are Java 8 closures really first-class values or are they only a syntactic sugar?

5条回答
  •  爱一瞬间的悲伤
    2020-11-27 16:55

    Yes, they are first class values (or will be, once Java 8 is released...)

    In the sense that you can pass them as arguments, compose them to make higher order functions, store them in data structures etc. You will be able to use them for a broad range of functional programming techniques.

    See also for a bit more definition of what "first class" means in this context:

    • http://en.wikipedia.org/wiki/First-class_citizen

提交回复
热议问题