6.1 Declaring and Initializing Arrays:

class ArrayDeclarationInit{
    public static void main(String[] args) {
        // Declaring an array of integers
        int[] numbers;

        // Initializing the array with values
        numbers = new int[]{1, 2, 3, 4, 5};

    }
}

6.2 Accessing Array Elements:

class ArrayAccessingExample{
    public static void main(String[] args) {
    
		int[] numbers = {1, 2, 3, 4, 5};

        // Accessing the first element
        int firstNumber = numbers[0];   
        System.out.println("firstNumber"+ firstNumber);// firstNumber: 1
        
        // Accessing the third element
        int thirdNumber = numbers[2];
        System.out.println("thirdNumber"+ thirdNumber);// thirdNumber: 3
    }
}

6.3 Array Length and Enhanced for Loop:

class Arraylength{
    public static void main(String[] args) {
		int[] numbers = {1, 2, 3, 4, 5};

        // Getting the length of the array
        int length = numbers.length;    
        System.out.println("length"+"="+ length); // length = 5
    }
}
class MultiArrayFor{
    public static void main(String[] args) {
		int[] numbers = {1, 2, 3, 4, 5};

        // Printing all elements using the enhanced for loop
            for (int number : numbers) {
                System.out.println(number);
            }
    }
}

6.4 Multidimensional Arrays:

Arrays can have multiple dimensions, allowing you to create tables or matrices.