It is necessary to create a method that outputs an array, I have an incomprehensible set of characters -[I@4554617c

 public static void main(String[] args) { int arr[] = new int[] {15,3,21,11}; System.out.println(task4(arr)); } public static int[] task4(int arr[]){ return arr ; } 

    2 answers 2

     System.out.println(Arrays.toString(task4(arr))); 

    For all classes of arrays, the default toString method is not overridden, and the default method of the Object class is called, the output of which you saw.

    Either manually iterate over the array and output it, or use the features built into the JDK — for example, the Arrays.toString method I used in the example at the beginning of the answer.

       public class TEST { public static void main(String[] args){ int arr[] = new int[] {15,3,21,11}; task4(arr); } public static void task4(int[] arr){ for(int i : arr){ System.out.println(i); } } }