0

I have an empty array, I would like to enter 3 numbers and stock these values inside.

int[] tab = new int[3];

for(int i=0;i<3;i++){
    System.out.print("Enter your number : ");
    int number = enter.nextInt();
    tab[i] = number;
}

System.out.print(tab);

I have an error message => I@4eec7777 I don't understand ?

Thank you for your help.

user11124425
  • 961
  • 1
  • 11
  • 22
  • 3
    That's not an error message. That's what an array looks like when you print it. – khelwood Nov 15 '19 at 09:21
  • 1
    An array in Java is printed by its reference, it does not print out the content. What you see is the reference to the array, but if you want to see its content, you have to print it out manually, e.g. by iterating over it and printing each element. – Philipp Nov 15 '19 at 09:26
  • @khelwood: Thank you, but how to print but 3 values after the loop? – user11124425 Nov 15 '19 at 09:32
  • @Philipp: I would like to print my 3 values at the end of my scanner – user11124425 Nov 15 '19 at 09:33
  • @user11124425 See https://stackoverflow.com/questions/409784/whats-the-simplest-way-to-print-a-java-array – khelwood Nov 15 '19 at 09:39

0 Answers0