Skip to main content
This revision made December 05, 2011 20:08, by Kin-man Chung

Collection Construction

The syntax for construction of collection objects follows the syntax that has been proposed for JDK 8 Collection literals. Note that EL 3.0 allows any expressions in the construction, and is not limited to literals.

List

  • Syntax: [1, "two", 3.0]
  • Implemented with java.util.ArrayList

Set

  • Syntax: {1, 2, 3}
  • Implemented with java.util.HashSet (LinkedHasSet?)

Map

  • Syntax: {"one": 1, "two": 2, "three": 3}
  • Implemented with java.util.HasMap

There is no syntax for construction of Java arrays. In most cases, List can be used instead. The method List.toArray() can be used to convert a List to an array, when needed (e.g. if the target type is an array).

Difference compared to previous revision
<span>=Collection Construction= The syntax for construction of collection objects follows the syntax that has been proposed for JDK 8 Collection literals. Note that EL 3.0 allows any expressions in the construction, and is not limited to literals. ==List== <span style="text-decoration:underline;color:green">* </span>Syntax: [1, "two", 3.0] <span style="text-decoration:underline;color:green">* </span>Implemented with java.util.ArrayList ==Set== <span style="text-decoration:underline;color:green">* </span>Syntax: {1, 2, 3} <span style="text-decoration:underline;color:green">* </span>Implemented with java.util.HashSet (LinkedHasSet?) ==Map== <span style="text-decoration:underline;color:green">* </span>Syntax: {"one": 1, "two": 2, "three": 3} <span style="text-decoration:underline;color:green">* </span>Implemented with java.util.HasMap There is no syntax for construction of Java arrays. In most cases, List can be used instead. The method List.toArray() can be used to convert a List to an array, when needed<span style="text-decoration:underline;color:green"> (e.g. if the target type is an array)</span>.<span>
 
 
Close
loading
Please Confirm
Close