java - A static method parseInt(char[]) that converts an array of numeric characters to an int value -
this question has answer here:
- what's simplest way print java array? 23 answers
here's 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 system.out.println(object.parseint(mychar));
values {'1','2','3'}
expect print myint
corresponding unicode values {'1','2','3'}
.
instead [i@15db9742
any ideas on i'm doing wrong?
that because printing object, hence java shows:
[i - name of type (in case 1 dimensional [ array of int) @ - joins string 15db9742the hashcode of object.
the memory address default. can use:
system.out.println(arrays.aslist(parseint(array)));
Comments
Post a Comment