Given an HTML form that uses checkboxes to allow a user to select multiple values for a parameter called hobbies.

Which EL expression evaluate to the first value of the hobbies parameter? (Choose all that apply.)

A. ${param.hobbies}
B. ${paramValue.hobbies}
C. ${paramValues.hobbies[0]}
D. ${paramValues.hobbies[1]}
E. ${paramValues[hobbies][0]}
F. ${paramValues[hobbies][1]}

Now the answer is AC and I am convinced by the answer.

However it says options E and F are incorrect syntax. How so ???. Yes it wouldn't return the desired value but why is it the incorrect syntax ???

If I try explaining option C. ${paramValues.hobbies[0]}

paramValues is a map of request parameters and it contains param name and array of possible values in the map. So container will start parsing the expression from left so it will first parse paramValues.hobbies that will return an array (say referenced by arr) of values for parameter hobbies next this expr will be reduced to ${arr[0]} that will give the first values in the array

On same lines if I try explaining option E. ${paramValues[hobbies][0]}

here first paramValues[hobbies] will be evaluated and it will look for hobbies as attribute first and since it won't find it, null will be returned so the expression evaluates to null and ${null[0]} will evaluate to null so it will evaluate to null or empty space will be printed if we use this expression.

1) Please let me know if I am interpreting the explanation wrongly.

2) Also I am a bit confused wherever . and [] get mixed in the expression. So logic is to evaluate it from left hand side taking one operator at a time.

3) Also if this were to be answered using only [] operator we will use it as ${paramValues["hobbies"][0]}, is this correct ??

I feel shy asking these type of questions as my exam date is nearing and still I am asking some very basic doubts

Kamal Tripathi
SCJP 1.4 90%, SCWCD5 94%, Next SCDJWS--> In Naescent stage. Researching abt exam and material itself.