0

Here's my code

public static int[] parseInt(char[] myChar)
{      
    int[] myInt = new int[myChar.length];
    for(int x = 0; x < myChar.length; x++)
    {
                myInt[x] = (int)myChar[x];
    }
    return myInt;
}

When I System.out.println(object.parseInt(myChar)); with values {'1','2','3'} I would expect it to print myInt with the corresponding unicode values for {'1','2','3'}.

Instead I get [I@15db9742

Any ideas on what I'm doing wrong?

ashiquzzaman33
  • 5,781
  • 5
  • 31
  • 42
Eric Schumann
  • 119
  • 1
  • 1
  • 9

1 Answers1

1

That because you are printing the object, hence java shows:

[I - the name of the type (in this case it is one dimensional [ array of int) 
@ - joins the string together
15db9742the hashcode of the object.

the memory address by default. You can use:

System.out.println(Arrays.asList(parseInt(array)));
Pshemo
  • 122,468
  • 25
  • 185
  • 269
Federico Piazza
  • 30,085
  • 15
  • 87
  • 123