File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

[] and dot operator

shanthisri mocherla
Ranch Hand

Joined: Sep 05, 2005
Posts: 119
Hi
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.

${mybean["objects"].a}

where as this statement does not give any error.


${mybean["params"].a}


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.
shanthi
Satish Ramasamy
Greenhorn

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [] and dot operator