Printing a container without any help, directly print the container object to obtain the visual data in the container, but for the array, directly print the array object, the final call to the ToString method, print out just:
* @return A string representation of the object. */Public String toString () {return getclass (). GetName () + "@" + Integer.tohexstring (Hashcode ()); }
Class name @hashcode.
Package hold the object. iterators; Import java.util.Arrays; Public class Test { publicstaticvoid main (string[] args) { int [] i = {A-i}; = {{"1", "2"},{"2"}}; System.out.println (i); System.out.println (s); }}
Output Result:
[[Email protected][[ljava.lang.string;@4e25154f
Where "represents the dimension of the array, L represents it as an array of reference types, and the array of reference types has its own class name." I represents it as a primitive type of array, with an array of primitive types with its own identity, such as the type of int identified as i,double type D.
Can be passed arrays.tostring (...) method to print visual data for an array
Package hold the object. iterators; Import java.util.Arrays; Public class Test { publicstaticvoid main (string[] args) { int [] i = {A-i}; = {{"1", "2"},{"2"}}; System.out.println (i); System.out.println (s); System.out.println (arrays.tostring (i)); System.out.println (arrays.tostring (s)); System.out.println (arrays.tostring (s[0]));} }
Output Result:
[ email protected][[ljava.lang.string;@4e25154f[1, 2, 3][[ljava.lang.string;@70dea4e, [ ljava.lang.string;@5c647e05][1, 2]
11th Chapter arrays.tostring (...) Printable representation of the resulting array