0

I am trying to initialize a simple array in java with 10 integers. Problem is that, no matter what I do, the output always comes completely different from what it is supposed to be. Example:

int[] example = new int[] { 2, 5, 7 };
System.out.println(example);

Result: [I@fd13b5

Another one:

int[] myList = {1,2,5,4,13,451,4};
System.out.println(myList);

Result:[I@7ffe01

Even if I do not assign anything to it:

int[] numberList = new int[10];
System.out.println(numberList);

Result: [I@1fae3c6

I really have no clue why it does this... Can someone please help? I don't know if it matters but I am using Eclipse. Thanks!

JMP
  • 4,417
  • 17
  • 30
  • 41

1 Answers1

0

You should print the array with

System.out.println(Arrays.toString(myList));

The default toString() implementation in Object class doesn't display the elements of the array.

Eran
  • 387,369
  • 54
  • 702
  • 768