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.
Arrays as parameters
Completing a method to print array elements
Report a typo
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 + " ");
}
}
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.