What’s the simplest way to print a Java array?

To print a Java array, you can use the Arrays.toString method, like this:

int[] array = {1, 2, 3, 4, 5};
System.out.println(Arrays.toString(array));

This will print the array in the following format: [1, 2, 3, 4, 5].

Alternatively, you can use a loop to print the elements of the array individually:

int[] array = {1, 2, 3, 4, 5};
for (int i : array) {
    System.out.println(i);
}

This will print each element of the array on a separate line.

These are the simplest ways to print a Java array.