Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hfs chap-8 qno-7 doubt

 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everybody

in the question one option is
${foo["5"] is valid syntax if foo is a Map
which is given correct.

i know that we can write an attribute name which doesn't follow the java rules for naming an identifier with double quotes inside [ ] while using EL i.e. will be valid

but can "5" be a key for a map ??? as it doesn't follow the java rules (can't start with a digit )
or am i missing some point here ??

avi sinha
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you can always put a "5" as a key in a map, "5" is after all a string, even you can have 5 as a key in a map as the compiler will autobox it into Integer. A key in the map needs to be an object whether String "5" or Integer 5 or anything else...
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops what was i doing ???

well i think i need a break.actually my exams are going on and a lot of cryptography , industrial management , distributed computing .... they are just playing cricket inside my mind.
unable to think properly
anyways thanks alot ankit

avi sinha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic