1

Here is the source code

class App {
public static void main(String[] args){

    int[] x = {0,1,2,3,4,5,6,7,8,9};
    int[] xcopy = java.util.Arrays.copyOfRange(x,0,3);

    System.out.println(xcopy);
}
}

The code compiles without error, but the result is this:

[I@659e0bfd

when it should be:

0,1,2

Why isn't this working? or more interestingly, where did the initial result come from?

DDKL
  • 11
  • 2
  • Hint: this is nothing to do with copyOfRange. `System.out.println(x)` would do the same thing. As would `System.out.println(new int[] {1, 2, 3});`. – user253751 Mar 24 '15 at 02:33

1 Answers1

0

You are trying to print out an array. You should be using a loop to iterate through the array and print out each individual int

Eymen
  • 141
  • 1
  • 10