my dog learned polymorphism
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes [] and dot operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "[] and dot operator" Watch "[] and dot operator" New topic

[] and dot operator

shanthisri mocherla
Ranch Hand

Joined: Sep 05, 2005
Posts: 119
can anyone please explain me this.

mybean is a bean of type MyBean.
objects is a List.
params is a Map.

These (objects and params)are the bean properties.

The following statement results in an error.


where as this statement does not give any error.


The explanation for this is since "objects " is NOT a Map, a lookup wont be performed as opposed to Map.

can anyone please explain me in detail.
thnks in advance.
Satish Ramasamy

Joined: Feb 13, 2006
Posts: 15
The dot operator works only when the left operand is a Bean or Map.

In case of ${mybean["objects"].a}, mybean["objects"] would be evaluated to a List object (which obviously doesn't have a property called "a") hence it results in error.

Thanks,<br />Satish<br /> <br />SCJP 1.4 - 98%
shanthisri mocherla
Ranch Hand

Joined: Sep 05, 2005
Posts: 119
Thanks Satish
Thanks for yor help.
It is sorta covered in the JavaRanch Style Guide.
subject: [] and dot operator
jQuery in Action, 3rd edition