(empty) operator, which evaluates to true if the expression evaluates to null, or evaluates to a container object that contains no items.
ternary operator for simple if-then-else (?
Joined: Aug 04, 2008
option E is correct. I tried it and it jumps to the otherwise condition. 'empty' works for empty lists and also if the object as such evaluates to null, as Micheal said.
SCJP 1.4 (86%)<br />SCWCD 1.5 (88%)
Joined: Oct 19, 2003
I checked with JSP2.0 Specification (Page: 1-73 Point: JSP.2.3.7). This is what I got from it.
JSP.2.3.7 Empty Operator - empty A The empty operator is a prefix operator that can be used to determine if a value is null or empty. To evaluate empty A, � If A is null, return true, � Otherwise, if A is the empty string, then return true. � Otherwise, if A is an empty array, then return true. � Otherwise, if A is an empty Map, return true, � Otherwise, if A is an empty Collection, return true, � Otherwise return false.
I also ran the example provided. For answers C and E, I got output as "I have not selected any favorite books."
I thought they were allowed to implement any way they choose but be required to meet the spec.
They do, but sometimes don't. Of course, they won't blunder such simple things like 'empty'. I didn't encounter much non-spec friendly behavior in SCWCD, but more in SCBCD. So trying something with a container is good, but does not guarantee 100% correctness.
Joined: Apr 20, 2002
Understood. I just had noticed that some posts were giving incorrect answers/information and thought that it would be better to have these posters discover the error for themselves. I tried to give a gentle nudge in the right direction :-).