• Post Reply Bookmark Topic Watch Topic
  • New Topic

Errata for OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide - page 192 (Sybex)  RSS feed

 
Bas Duineveld
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code snippet:
Text: "On the infinite list, one match is found, so the call [to anyMatch()] terminates. If we called noneMatch() or allMatch(), they would run until we killed the program."
This is incorrect. noneMatch() also terminates immediately, returning false. Apart from that, I would say the term "infinite list" is incorrect and should read "infinite stream".
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bas,
Agreed and logged. And welcome to CodeRanch!
 
Tomas Castagnino
Ranch Hand
Posts: 31
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi!

I think there is something a little bit confusing with that paragraph. Granted, it is true that this would terminate:



But this, I think, would not:



And although it is never said in the paragraph that the noneMath() method ALWAYS terminates, the correction may lead someone to (mistakenly) assume that it does (I almost did).

Regards,

Tomás
 
Tomas Castagnino
Ranch Hand
Posts: 31
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yes, I realize that first paragraph states that those methods “may or may not terminate for infinite stream”. So there is no errata in there. Mine was just a friendly note on the perhaps confundent (?) feeling I get when reading that section + the corrected errata.
 
Jorge Ruiz-Aquino
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the last paragraph of allMatch(), anyMatch() and noneMatch().
"noneMatch() also returns false because one matches" should say "noneMatch() also returns false because two match"
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jorge Ruiz-Aquino wrote:In the last paragraph of allMatch(), anyMatch() and noneMatch().
"noneMatch() also returns false because one matches" should say "noneMatch() also returns false because two match"

It's right as is. As soon as noneMatch() sees a match, it stops looking. There could be one or a million. It's only the first match that matters.
 
Jorge Ruiz-Aquino
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes sense. Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!