Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Possible errata in OCP study book  RSS feed

 
Greenhorn
Posts: 4
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, im studying to get the OCP Java 8 certification.

I'm readinn the book "OCP Oracle Certified Professional Java SE 8 Programmer II Study Guide, by Jeanne Boyarsky and Scott Selikoff"

I have a doubt, in page 59, there is a lambda example, that I think that there is no possible way to assign it to a Functional Interface:




For example, the next lambda expression:



can be successfully asigned to a IntConsumer:



greetings

Jaime Reyes

 
Master Rancher
Posts: 2563
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Jaime,

welcome to the Ranch and enjoy the stay!

I think you are correct. I could not come up with code that accepted

The 'int' must be replaced by 'Integer'.
The Functional Interface is here a BiFunction, for instance

Replacing Integer by int gives an error.
 
Jaime Rebel Gaiden
Greenhorn
Posts: 4
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I was just focusing on already created Functional Interfaces, but, I found there is a way to make it compile successfully:



an the caller

 
Piet Souris
Master Rancher
Posts: 2563
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right. Have a cow!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!