In a Java program, you're given an integer array that you need to print to the console. However, the method which is responsible for printing the array and the main method where this is called are missing some parts. The integer array is defined in the main method and called 'numbers'. Your task is to fill the blanks in code to accomplish that.
Arrays as parameters
Completing code to print an integer array
Report a typo
Fill in the gaps with the relevant elements
public class Main {
main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5};
printArray(numbers);
}
public static void printArray(int[] array) {
(int num : array) {
("Number: " + num);
}
}
} ___
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.