Introduction to Java Arrays

In this section you will be introduced to the concept
of Arrays in Java Programming language. You will learn how the Array class in
java helps the programmer to organize the same type of data into easily manageable
format.
Program data is stored in the variables and takes
the memory spaces, randomly. However, when we
need the data of the same type to store in the contiguous memory
allocations we use the data structures like arrays. To meet this feature java
has provided an Array class which abstracts the array data-structure.
The java array enables the user to store the values of
the same type in contiguous memory
allocations. Arrays are always a fixed length
abstracted data structure which can not be altered when required.
The Array class implicitly extends java.lang.Object
so an array is an instance of Object.
Advantages of Java Array:
- An array can hold primitive types
data.
- An array has its size that is known
as array length.
- An array knows only its type that it
contains. Array type is checked at the compile-time.
Disadvantages of Java Array:
- An array has fixed size.
- An array holds only one type of data
(including primitive types).

|