Maurice Naftalin's Lambda FAQ

编程入门 行业动态 更新时间:2024-10-20 09:26:10

Maurice Naftalin's Lambda <a href=https://www.elefans.com/category/jswz/34/1755531.html style=FAQ"/>

Maurice Naftalin's Lambda FAQ

2019独角兽企业重金招聘Python工程师标准>>>

详细目录请看:/


  • Home

  • About the Lambda FAQ

  • Lambda resources

  • Ask the FAQ

Maurice Naftalin's Lambda FAQ

Your questions answered: all about Lambdas and friends

CommentsPosts

 

 

 

 

Fundamentals

  • What is a lambda expression?

  • Why are lambda expressions being added to Java?

  • What is a functional interface?

  • What is the type of a lambda expression?

  • Are lambda expressions objects?

  • Where can lambda expressions be used?

  • What are the scoping rules for lambda expressions?

  • Can lambda expressions be used to define recursive functions?

  • Can lambda expressions use variables from their environment?

  • What are method references?

  • What is the syntax for instance method references?

  • What are constructor references?

Default Methods

  • What are default methods?

  • Do default methods introduce multiple inheritance to Java?

  • How are conflicting method declarations resolved?

  • What about the diamond problem?

Collections

  • Where is the Java Collections Framework going?

  • What is a stream?

Idioms and Techniques

  • How can I get the last element of a stream?

  • How can I get a stream with a number of repeated elements?

  • How can I turn an Iterator or an Iterable into a Stream?

  • How can I turn a Stream into an Iterable?

  • How can I use Streams to repeat an action a certain number of times?

  • How can I turn an Iterator into a List?

  • How can I turn an Iterator into an Iterable?

  • How can I perform bulk array operations using lambdas?

  • How can I turn an array into an Iterator?

  • Are there other constant lambdas like Function.identity()?

Design Rationale

  • Why are lambda expressions being added to Java?

  • Are lambda expressions objects?

  • Why the restriction on local variable capture?

  • Where is the Java Collections Framework going?

  • Why are Stream operations not defined directly on Collection?

  • Why are lambda expressions so-called?

  • Why can't default methods override equals, hashCode, and toString?

  • Why do default methods need a keyword?

  • Why is there no shorthand syntax for invoking a lambda?

  • Why are static methods split between the Collector interface and the Collectors class?

Advanced Questions

  • Lambdas and closures — what's the difference?

  • In what order do the elements of a stream become available?

  • How can I get distinct() to compare some derived value instead of the stream elements themselves?

Meta

  • Log in

  • EntriesRSS

  • CommentsRSS

  • WordPress

About the Lambda FAQ

Lambdas are now becoming a familiar part of the Java scenery. Java 8 shipped on March 18th this year, bringing with it the long-awaited feature of lambda expressions (aka closures). Together with the associated language and library features—streams and virtual extension methods—they are having a greater impact on how we program in Java than any other change in the history of the platform.

I initially started to learn about the new features so that Phil Wadler and I could consider a second edition of our book Java Generics and Collections. But as I learned more about the subtleties of the changes, it became clear that an entire new book (Mastering Lambdas) was needed. Writing that has used up my spare cycles for nearly a year, but I’m happy now to turn my attention back to this FAQ. And though of course I’m urging you to buy the book, it’s not the end of wisdom on the subject: as I learn more and we get greater experience in using the new features, new understanding can be reflected here.

The new features weren’t all easy to understand at first, so this FAQ started with the intention of helping you over some of the obstacles that tripped me up. But then more advanced questions appeared, so I now hope that you will find it useful whether you are already familiar with lambda expressions or encountering them for the first time. All comments and contributions are welcome. I’m very pleased to acknowledge the continuing input from the Oracle Java Language and Tools team, especially Stuart Marks and Brian Goetz; their collaboration is helping to greatly improve the scope and accuracy of this document. (Of course, all errors and omissions are my responsibility.)  I will be happy to include and acknowledge your contribution too. But please be aware that anything on this website may yet end up as part of the material of a new edition of Java Generics and Collections.

What’s the Purpose of this FAQ?

The question-and-answer format is intended to serve two purposes;

  • It’s a tutorial: if you’re starting from scratch in learning about the upcoming changes to Java, you should be able to start with the first question, “What is a lambda expression?” and get a tutorial introduction by following the “next” link at the top right of each page;

  • It’s a reference: if you want an answer to a particular technical question, jump straight to it. Since the Oracle team are also reading these answers, it’s reasonable to expect that this will become an authoritative popular reference to what’s going to happen.

    • As part of the reference material, there’s a resources page, where I will maintain up-to-date links with the various rapidly-changing useful resources: documentation, presentations, build and download resources, tool support and mailing lists.

The tutorial sequence is divided into topics, to be read in the sequence listed below and in the left-hand sidebar on every page, which also corresponds to the “next” and “previous” links at the top of each post. An exception is the topic of “Design Rationale”; some questions here can also be found in the tutorial sequence, others are free-standing.

What’s Your Question?

Let me know what you think of this resource, how it could be improved, and what questions you would like to see answered here. Ask the FAQ!

1: Fundamentals of Lambda Expressions

What is a lambda expression?
Why are lambda expressions being added to Java?
What is a functional interface?
What is the type of a lambda expression?
Are lambda expressions objects?
Where can lambda expressions be used?
What are the scoping rules for lambda expressions?
Can lambda expressions be used to define recursive functions?
Can lambda expressions use variables from their environment?
What are method references?
What is the syntax for instance method references?
What are constructor references?

2: Default Methods

What are default methods?
Do default methods introduce multiple inheritance to Java?
How are conflicting method declarations resolved?
What about the diamond problem?

3: Collections

Where is the Java Collections Framework going?
What is a stream?

Questions about Design Rationale

(Questions labelled “(t)” are also included in the tutorial sequence above)

Why are lambda expressions being added to Java? (t)
Are lambda expressions objects? (t)
Why the restriction on local variable capture?
Where is the Java Collections Framework going? (t)
Why are Stream operations not defined directly on Collection?
Why are lambda expressions so-called?

Advanced Topics

Lambdas and closures—what’s the difference?

Copyright © 2015 Maurice Naftalin's Lambda FAQ - All Rights Reserved
Powered by WordPress & Atahualpa            


转载于:

更多推荐

Maurice Naftalin's Lambda FAQ

本文发布于:2024-03-06 14:17:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1715520.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Naftalin   Maurice   FAQ   Lambda

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!