[] (array access)

本参考资料用于Processing 3.0+。 如果你使用的是前一版本,请在使用软件帮助菜单内的参考资料。. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.


[] (array access)

int[] numbers = new int[3];

 numbers[0] = 90;

 numbers[1] = 150;

 numbers[2] = 30;

a = numbers[0] + numbers[1];

// Sets variable 'a' to 240 
int b = numbers[1] + numbers[2];

// Sets variable 'b' to 180  
描述 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.
 datatype[] array[element] 
datatype any primitive or compound datatype, including user-defined classes
array any valid variable name
element int: must not exceed the length of the array minus 1
相关 Array

Updated on October 2, 2018 05:02:17pm EDT

[] (array access)