Array returning memory allocation instead of value in Java -
this question has answer here:
consider simple case 1 :
public static void array() { string mystring = "stackoverflow"; int [] checkval = new int[mystring.length()]; for(int i=0; i<mystring.length();i++){ checkval[i] = (int)mystring.charat(i); } system.out.println(checkval[0]); system.out.println(checkval[1]); system.out.println(checkval[2]); system.out.println(checkval[3]); system.out.println(checkval[4]); system.out.println(checkval); }
this output following :
83 84 65 67 75 [i@fc9944
can 1 please explain me ? how can retrieve proper information array instead of it's memory allocation ?
if want pretty printed, use arrays.tostring
it:
system.out.println(arrays.tostring(checkval);
if not, print out tostring
of array, inherited object
, , generated string
contains type , hash code:
the tostring method class object returns string consisting of name of class of object instance, at-sign character `@', , unsigned hexadecimal representation of hash code of object. in other words, method returns string equal value of:
getclass().getname() + '@' + integer.tohexstring(hashcode())
this answer has relevant info.
Comments
Post a Comment