Java Reference
In-Depth Information
Table 3-2. ( continued )
If a seed value is specified, then it is assigned to an internal accumulator variable.
Iterates over the source elements, repeatedly computing the next accumulator value by
invoking the specified function and passing the current accumulator value as the first
argument and the current element as the second argument. At the end of the iteration,
if a resultSelector is not specified, the final accumulator value is returned; otherwise,
resultSelector function is invoked, passing the final accumulator as its argument, and
the result is returned.
If no seed value is specified, then the value of the first element is used as the seed value.
If the source collection is empty, the aggregate operator without a seed value throws an
InvalidOperationException .
Iterates over the source elements and applies the action function to each element. The
action can take two arguments. The first argument of action represents the element to
process. The second argument, if present, represents the zero-based index of the element
within the source collection.
The forEach operators always return null .
it is important to note that zero or more operators can be chained together to achieve the desired result.
For instance, you can apply a select operator to a collection and then apply a where operator to that same collection.
New Operators
New operators have been added to EL in order to bring new features to the language. This section will cover each of
the new operators and provide a brief example for each. Lastly, there have been some operator precedence changes in
order to accommodate the new additions to the language, so I'll cover them as well.
String Concatenation Operator
The String concatenation operator works if and only if one of the operands is a String . The new operators for
concatenation are + and cat . Since the + operator has been overloaded, if both operands are numeric values, then it
adds the two together; otherwise, if one operand is a String , then concatenation will occur.
The following examples demonstrate the use of the new + operator for concatenation:
${"Hello " +}
${100 + "3"} // produces: 1003
The other concatenation operator, cat , is used in the following way:
${"Hello ".cat(}
Search WWH ::

Custom Search