Object Class (root class), object class

Source: Internet
Author: User

Object Class (root class), object class

The methods in the Object are all methods in the class. Each class inherits the Object class by default.

Boolean equals (Object obj): the default comparison address in the Object. You can override the equals (Object obj) method to compare the content.

 

String toString (): returns the String representation of this object, object. toString ();

The result is the hash value of the class to which the object belongs plus @ object (getClass (). getName () + '@' + Integer. toHexString (hashCode ())).

Int hashCode (): Get the object's hash value. The result is an Integer. Use Integer. toHexString (object. hashCode (); convert it to hexadecimal.

Class <?> GetClass (): returns the runtime class of the Object, an Object of the Object class.

 

For Class <?> Understanding: The Person class is the abstract of a Person, and the third and fourth are the concrete implementations of a Person. getName () is a common method of a Person,

The Class can be regarded as Person, A. class, and B. class. getClassName () gets the Class name.

It is equivalent to abstracting all Class files into class classes. Class files of specific classes are implemented, and class classes have common methods for specific Class files.

 

Related Article

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.