Arrays and lists
You can build arrays for the following primitives:
-
byte
-
short
-
int
-
long
-
float
-
double
-
char
-
boolean
For example, new <type>[<size>]
or
new <type>[] {<comma-separated values>}
.
You can use lists such as {<comma-separated values>}
.
Lists can contain both non-primitives and primitives. |
Access arrays and lists using [index]
.
Array or list type | Example |
---|---|
int array |
|
float array |
|
Array initializer |
|
2-dimensional array (cannot have initializer) |
|
Initializing and accessing array |
|
Accessing array property |
|
Empty list |
|
Integer list |
|
String list |
|
Accessing list element |
|
List with property references |
|