Completing a method to print array elements

Report a typo

You are given a partially completed Java program, and your task is to fill in the blanks in its code. The program should define an array of integers, pass it as an argument to a method, and then print out each element of the array within the method. The code within the main method and the printArray function are incomplete. Please fill in the missing parts of the program so that it works as expected.

Fill in the gaps with the relevant elements
public class Main {
    public   main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        (arr);
    }

    static void printArray(int[] array) {
        for (int element : array) {
            System.out.print(element + " ");
        }
    }
}
staticprintArrayvoid
___

Create a free account to access the full topic