File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in EL [] operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in EL [] operator" Watch "Doubt in EL [] operator" New topic

Doubt in EL [] operator

Sahul Yasin
Ranch Hand

Joined: Aug 28, 2002
Posts: 48
List list = new ArrrayList();


What will be the value of output?

I thought that list['listIdx'] will return 0, since 'listIdx' is in quotes.(Quoted 'listIdx' is not an index of list, so the default value 0). & hence list[0] returns 'a'.

But according to HFSJ "c" is the correct answer (Page: 428)
I think,the term inside [] evaluated only if it is not in quotes.[Page 396, 7th bullet point].

Pls advice where I misunderstood. Thanks.

Regards,<br />Yasin<br />SCJP,SCWCD,SCBCD
Hunny Lee

Joined: Feb 17, 2007
Posts: 23
list['listIdx'] will throw an exception since 'listIdx' is a String, and not an integer used to retrieve the values in the list [i.e. get(int index)]

I checked the errata of HFSJ at and it looks like the correct option was

[ February 21, 2007: Message edited by: Hunny Lee ]
I agree. Here's the link:
subject: Doubt in EL [] operator
It's not a secret anymore!