11th Chapter arrays.tostring (...) Printable representation of the resulting array

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.