Forums Register Login

Possible errata in OCP study book

+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send
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.
(1 cow) 1
+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send
You are right. Have a cow!
Water! People swim in water! Even tiny ads swim in water:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 332 times.
Similar Threads
OCAJP 8
Cleared OCA java 8 certification and need preparation inputs for OCP java 8 exam
Where to learn Java?
* Welcome S.G. Ganesh, Hari Kiran Kumar, & Tushar Sharma
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:41:47.