Reference×
Reference
- [] (array access)
- = (assign)
- catch
- class
- , (comma)
- // (comment)
- {} (curly braces)
- /** */ (doc comment)
- . (dot)
- draw()
- exit()
- extends
- false
- final
- implements
- import
- loop()
- /* */ (multiline comment)
- new
- noLoop()
- null
- () (parentheses)
- popStyle()
- pop()
- private
- public
- pushStyle()
- push()
- redraw()
- return
- ; (semicolon)
- setLocation()
- setTitle()
- setResizable()
- setup()
- static
- super
- this
- thread()
- true
- try
- void
Name
[] (array access)
Description
The array access operator is used to specify a location within an array. The data at this location can be defined with the syntax array[element] = value and read with the syntax value = array[element] as shown in the above example.
Examples
int[] numbers = new int[3]; numbers[0] = 90; numbers[1] = 150; numbers[2] = 30; int a = numbers[0] + numbers[1]; // Sets variable 'a' to 240 int b = numbers[1] + numbers[2]; // Sets variable 'b' to 180
Syntax
datatype[]
array[element]
Parameters
datatype
any primitive or compound datatype, including user-defined classesarray
any valid variable nameelement
int: must not exceed the length of the array minus 1
Related

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.