Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Question/Errata for OCP:Oracle Certified Professional Java SE 8 Programmer II Study Guide - page 557

 
Ranch Hand
Posts: 44
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

For the answer to question 14 on page 557, I was wondering if the second "autoboxing" shouldn't be understood as "unboxing" since we are converting to a primitive like explained?

Thanks for your answer.

Kind regards,
Guillaume
 
author & internet detective
Posts: 40400
821
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guillaume,
You are correct and I logged it. This is a case of "sloppy" English.

Autoboxing does mean primitive to object and unboxing means object to primitive. Sometimes people (incorrectly) use autoboxing to refer to both ways. I mention this because you could easily encounter this "sloppy English" problem in other books or even when talking to people in the workplace. Which means it is good to be suspicious when you hear "autoboxing" and consider it might be meant either way.
 
Guillaume Bailly
Ranch Hand
Posts: 44
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the explanation. I will pay attention in the future, now even more :-)
 
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The explanation says: Converting from a double to an int would require a cast inside the lambda, but
7: Stream<Integer> s2 = ds.mapToInt(x -> (int)x); still doesn't work. mapToInt has to be replaced by mapToObject.
Furthermore line 6 throws an IllegalStateException: stream has already been operated upon


 
Jeanne Boyarsky
author & internet detective
Posts: 40400
821
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Juerg Bauman wrote:The explanation says: Converting from a double to an int would require a cast inside the lambda, but
7: Stream<Integer> s2 = ds.mapToInt(x -> (int)x); still doesn't work. mapToInt has to be replaced by mapToObject.


Actually mapToObj. And yes, I've added that to the errata. A cast isn't needed in any event.

Juerg Bauman wrote:Furthermore line 6 throws an IllegalStateException: stream has already been operated upon


While that's true, the question and explanation are about compiling. The runtime exception is a "decoy" answer to try to trick you.
 
Nothing? Or something? Like this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic