• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Ranch Hand
Posts: 477
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: 74376
334
  • 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: 477
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: 74376
334
  • 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: 40798
829
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic