Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The dot(.) operator and [] operator

 
Kim Lauwers
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

Is there a site or something witch explanes me these two operators because I find them rather difficult.

Or if someone can explain me this shortly.

I'm using HFSJ for studying.

thx
 
Kim Lauwers
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Little question about it.

When a have a map:
java.util.Map someMap = new java.util.HashMap();
someMap.put("key","value");

someMap["key"] -->will return value?
map[key]--> wil return null?

correct?
 
Balasubramani Dharmalingam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${someMap["key"]}
In this case it will return the object from someMap that mapped to string "key" will be return.

${someMap[key]}
In this case the value for the key ( equivalent to ${key} ) is evaluated then the object mapped for that value will be return.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.util.Map someMap = new java.util.HashMap();
someMap.put("key","value");

someMap["key"] --> request.getAttribute(someMap.get("key")) --> value
someMap[key]--> request.getAttribute(someMap.get(request.getAttribute("key")) --> null
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic