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];\text{datatype array name}[] = \text{new datatype}[size];
  • Example: int arr[]=new int[10];int\text{ arr}[] = \text{new int}[10];
  • Indices for an array of size 1010 range from 00 to 99.

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];\text{datatype array name}[][] = \text{new datatype}[row][column];
  • Example: int arr[][]=new int[3][4];int\text{ arr}[][] = \text{new int}[3][4];
  • Example calculation based on indexed values:
    • If arr[0][2]=7arr[0][2] = 7 and arr[2][0]=80arr[2][0] = 80
    • Then arr[0][2]+arr[2][0]=7+80=87arr[0][2] + arr[2][0] = 7 + 80 = 87