0

new to coding, new to java and new to stack overflow.

It might be a silly question, but I'm having trouble creating an int array of size = HashMap.size();

 int gt = HashMap.size(); // which is 50
 int[] answer = new int[gt]; // Shouldn't it creates an int array of size 50?
 int length = answer.length;      
      System.out.println(answer + " " + length); // is giving me something 
 like [I@15db9742 50

Any idea of what's going on? THANKS!

Sunny Xu
  • 31
  • 1
  • 5
  • Does HashMap.size() return 50 or somthinge else+ – Peter Oct 05 '17 at 07:50
  • Printing answer makes you print the address to the answer array, not its lenght – Peter Oct 05 '17 at 07:51
  • 1
    @Peter The `15db9742` value is not an address. It's a hash code. See "[How do I print my Java object without getting “SomeType@2f92e0f4”?](https://stackoverflow.com/q/29140402/5221149)" for a good background description. – Andreas Oct 05 '17 at 08:09
  • @Andreas Thanks for the clarification, I can actually see my int array now by printing every element out using a for loop. – Sunny Xu Oct 05 '17 at 08:29

0 Answers0