GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • Download
  • Reference
  • Environment
  • Libraries
  • Tools
  • Wiki
  • Tutorials
  • Examples
  • Books
  • Forum
  • Overview
  • People
  • Privacy

This view

  • Original page
  • New address

GeezerVison is showing processing.org — [] (array access) / Reference

Reference+
Documentation→Reference→Structure

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

  • datatypeany primitive or compound datatype, including user-defined classes
  • arrayany valid variable name
  • elementint: must not exceed the length of the array minus 1

Related

  • Array
Creative Commons License

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

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.