Java API, common object, and javaapi object

Source: Internet
Author: User

Java API, common object, and javaapi object

I. Object Class

Overview: a. root class of the class hierarchy

B. All classes are directly or indirectly inherited from the class.

Ii. Constructor

Public Object ()

The subclass constructor accesses the non-argument constructor of the parent class by default.

Iii. Member Methods

1. public int hashCode ()

A. Return the hash value of the object. By default, this method is calculated based on the object address.

B. The hashCode () of different objects will not be the same in general.

2. public final Class getClass ()

A. Return the runtime class of this Object

B. You can use a method in the Class to obtain the full name of the real Class of the object.

3. public String toString ()

A. Return the String of this object to indicate public String toString (){

Return name + "," + age;

}

B. Its value is equal:

GetClass (). getName () + "@" + Integer. toHexString (hashCode ())

C. The data by default is meaningless to us.

4. equals method of Object Class

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.