• 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
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

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

 
Ranch Hand
Posts: 415
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 71028
291
  • Mark post as helpful
  • send pies
  • 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: 415
8
  • Mark post as helpful
  • send pies
  • 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: 71028
291
  • Mark post as helpful
  • send pies
  • 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: 40283
819
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic