Java Arrays

An array is a collection of variables of the same type. It stores a fixed size sequential collection of elements of the same type. An array is used to store a collection of data.

Arrays are declared with [] (square brackets). If you put [] (square brackets) after any variable of any type only that variable is of type array remaining variables in that declaration are not array variables those are normal variables of that type. If you put [] (square brackets) after any data type all the variables in that declaration are array variables. All the elements in the array are accessed with index. The array element index is starting from 0 to n-1 number i.e. if the array has 5 elements then starting index is 0 and ending index is 4. In this tutorial you can learn how to declare arrays, how to assign values to arrays and how get values from arrays.

Syntax:
< data type > < variable >[];
< data type >[] < variable >

In this tutorial you can learn Java Arrays with the following Java Primitive Data Types.