Page created: 20 Jan 2022
|
Page updated: 10 May 2023
You can build arrays for the following primitives:
- byte
- short
- int
- long
- float
- double
- char
- boolean
new
<type>[<size>]
or
new <type>[] {<comma-separated
values>}
.You can use lists such as {<comma-separated
values>}
.
Note:
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 |
|