posted 17 years ago
<%
List list = new ArrrayList();
list.add("a");
list.add("2");
list.add("c");
request.setAttribute("list",list);
request.setAttribute("listIdx","1");
%>
${list[list['listIdx']]}
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