Introduction to Arrays and Classification of Arrays in Java
Overview of Arrays
- Arrays are used to store a finite number of data of a similar type.
- They are classified as user-defined non-primitive data types.
- Date of Reference: 16/09/2026.
Types of Arrays
- There are two primary types of arrays in Java:
- Single dimensional array (SDA)
- Double dimensional array (DDA)
Single Dimensional Array (SDA)
- Syntax: datatype array name[]=new datatype[size];
- Example: int arr[]=new int[10];
- Indices for an array of size 10 range from 0 to 9.
Double Dimensional Array (DDA)
- A Double dimensional array is utilized to organize data into rows and columns.
- Syntax: datatype array name[][]=new datatype[row][column];
- Example: int arr[][]=new int[3][4];
- Example calculation based on indexed values:
- If arr[0][2]=7 and arr[2][0]=80
- Then arr[0][2]+arr[2][0]=7+80=87