Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 493
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: 77539
372
  • 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: 493
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: 77539
372
  • 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: 41578
881
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.
 
Can't .... do .... plaid .... So I did this tiny ad instead:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic