• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Sybex 816 Java OCP 11 Programmer II Study Guide Map.ofEntries Errata

 
Ranch Hand
Posts: 499
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Map also provides a method that lets you supply key/value pairs.



VitalSource page 129 typo?:
Exception in thread "main" java.lang.IllegalArgumentException: duplicate key: key1
 
Marshal
Posts: 80140
418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Map#ofEntries() clearly says it throws that exception if the “K”s in the Entries are duplicated. If you have copied that code exactly then there is a typo in it.
 
Charles O'Leary
Ranch Hand
Posts: 499
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:If you have copied that code exactly

Yes.

Campbell Ritchie wrote:then there is a typo in it.

Thanks for the confirmation.
 
Campbell Ritchie
Marshal
Posts: 80140
418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Last night, I wrote:then there is a typo in it.

Or it is intended to show the exception being thrown.

Thanks for the confirmation.

That's a pleasure
 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Definitely a typo. The second line should say "key2" just like in the example above it.

Thanks for reporting. I've added it to the errata list.
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic