arrays - Object[] inside Object[] Java returns memory address? -
trying access object[]
inside initial object[]
returns memory address i.e. system.out.println(object[1]);
.
how return contents instead?
when call system.out.println
on array (or other object matter), implicitly invoke tostring()
method (assuming it's not null
, of course). arrays implement in trivial manner, so, mentioned, address, not useful.
arrays.tostring
should give more useful output:
system.out.println(arrays.tostring(objects[1]));
or better yet, use arrays.deeptostring
print entire "parent" array:
system.out.println(arrays.deeptostring(objects));
Comments
Post a Comment