Mikalai Zaikin wrote:
No, you are passing it as a method argument; you don't pass anything to a class.Anil Philip wrote:. . . In the traditional way you are passing the parameter to the implementing class
No, you are creating an object of a class implementing Sprint and then passing the 10 as an argument to its method.. . . But now you are invoking the method on the lambda expression while passing the parameter to it!
I would suggest you try a book like Modern Java in Action by Urma, Fusco, and Mycroft (Manning, 2017 and earlier editions). That gives a lot of explanation of λs from the ground up.Anil Philip wrote:. . . I was trying to understand from first principles. . . .
Campbell Ritchie wrote:
No, you are passing it as a method argument; you don't pass anything to a class.Anil Philip wrote:. . . In the traditional way you are passing the parameter to the implementing class
Campbell Ritchie wrote:
No, you are creating an object of a class implementing Sprint and then passing the 10 as an argument to its method.Anil Philip wrote:. . . But now you are invoking the method on the lambda expression while passing the parameter to it!
No, you are passing the argument to the method of the Tiger object.Anil Philip wrote:. . . . We are passing the parameter to the method on the Tiger class. . . .
Sort of. It creates a class representing that Sprint object, rather like what an anonymous class used to be. Don't say, “class instance;” say, “instance.”So Java is creating an anonymous class instance of the Sprint interface?
Campbell Ritchie wrote:
I would suggest you try a book like Modern Java in Action by Urma, Fusco, and Mycroft (Manning, 2017 and earlier editions). That gives a lot of explanation of λs from the ground up.Anil Philip wrote:. . . I was trying to understand from first principles. . . .
So what? It is probably the best book for that particular purpose. λs have hardly changed since Java8. You will probably get an old edition second‑hand for less than the newer edition.Anil Philip wrote:. . . I looked up the book you recommend - it was not updated after Java 9 . . .
That's a pleasureAnil Philip wrote:. . . Thanks.
That is because such a question won't come up in the exam. I personally think, if you want to learn programming, it is better to enrol as a student at a proper course than think you can learn it for a cert. exam. Cert. exams test knowledge of the rules of Java® rather than programming best practice. But that doesn't mean that cert. exams are at all easy.The Boyarsky book does not cover rolling ones own Functional Interface and calling it. . . .
Anil Philip wrote:I looked up the book you recommend - it was not updated after Java 9
Anil Philip wrote:Thanks. The Boyarsky book does not cover rolling ones own Functional Interface and calling it.
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:Can you give an example of what you think should be covered? This seems pretty thorough to me.
How do you it is one instance per λ? How do you know that instances are not cached and reused?Anil Philip wrote:. . . for each and every lambda expression that is passed in, Java creates one anonymous class instance of the Functional Interface. . . .
Is it? Do you really need to know that?. . . critical information that was missing . . . It is a gap.
Campbell Ritchie wrote:
How do you it is one instance per λ? How do you know that instances are not cached and reused?Anil Philip wrote:. . . for each and every lambda expression that is passed in, Java creates one anonymous class instance of the Functional Interface. . . .
Campbell Ritchie wrote:
Is it? Do you really need to know that?. . . critical information that was missing . . . It is a gap.
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|