Java Reference
In-Depth Information
• Set object construction:
The construction of
Set
collection type results in an instance of
Set <Ob-
ject>
and it is done according to the following syntax:
SetCollectionObject = '{'elements '}'
Here,
elements
has the form
(expression (',' expression)* )?
For example:
{1, 2, 3, 4, 5}, {'one','two','three','four'},
{1.3, 2, 3,{4.9, 5.1}}
• List object construction:
The construction of
List
collection type results in an instance of
List<Ob-
ject>
and it is done according to the following syntax:
ListCollectionObject = '['elements']'
Here,
elements
has the form
(expression (',' expression)* )?
For example:
[one, 'two', ['three', 'four'],five], [1, 2,
3, [4,5]]
• Map object construction:
The construction of
Map
object type results in an instance of
Map<Object>
and it is done according to the following syntax:
MapCollectionObject = '{' MapElements '}'
Here,
MapElements
has the form
(MapElement (',' MapElement)*
)?
and
MapElement
the form
expression ':' expression
For example:
{1:'one', 2:'two', 3:'three', 4:'four'}