Java Array

In this chapter you will learn:

  1. What are arrays in Java
  2. Java Array Index
  3. Java Array Index Value

Description

An array is a named set of variables of the same type.

Each variable in the array is called an array element.

Index

To reference an element in an array, we use the array name combined with an integer value, called index.

The index is placed between square brackets following the array name; for example,

data[9]

refers to the element in the data array corresponding to the index value 9.

Index Value

The index for an array element is the offset of the element from the beginning of the array.

The first element has an index of 0, the second has an index of 1, the third an index of 2, and so on.

data[9] refers to the tenth element in the data array.

The index value does not need to be an integer literal, it can also be a variable.

The array index has to have a value equals to or greater than zero.

Next chapter...

What you will learn in the next chapter:

  1. What is Java array variable
  2. Syntax for Java array variable definition
  3. Note for Java array variable definition
  4. Alternative Syntax for Java array variable definition
  5. Create an array
  6. Single statement for declare and create an array
Home »
  Java Tutorial »
    Java Langauge »
      Java Array
Java Array
Java Array Variables
Java Array Initial Values
Java Array Length
Java Initialize Arrays
Java Array Index
Java Array for each loop
Java Multidimensional Arrays