Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HFSJ 2nd edition - wrong answer marked as correct

Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 8, page 433, Answer for question 7.
Option C should not be marked, since ${foo["5"]} works fine for arrays and Lists, "5" is coerced to an int.
what do you think ?

Option C:
${foo["5"]} is valid syntax if foo is a Map

I think I am wrong, since the enunciation sentence doesn't exclude arrays and Lists from the context, they just assume that foo is a Map.
so option 7c is good.
I guess I took it as "${foo["5"]} is valid syntax ONLY if foo is a Map " which has a slightly different meaning.
Ranch Hand
Posts: 461
Scala jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't this saying get me the value from the map foo where the key is "5" so it is valid, same as the Java syntax Map.get(Object key) - I may be wrong though!
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic