Java source-object

Source: Internet
Author: User

Java.lang.Object

The object class is the base class for all other classes in Java, and all other classes inherit the base class by default, and the methods in that class are 13, as follows

Registernatives () method
    Private Static native void registernatives ();     Static {        registernatives ();    }

This method is decorated by native, which means that the method is not implemented in Java, but is done by C + +, and we do not need to pay attention to this method for the time being.

GetClass () method
 Public Final native Class<?> getclass ();

The method returns a Class object/Runtime class object for object class<?>

Hashcode () method
 Public native int hashcode ();

The Hashcode () method returns an integer that represents the hash code value of the object.

For the same object, the hash code value of the object is returned with the same

Equal (Object obj) method
     Public Boolean equals (Object obj) {        return ( this = = obj);    }

Used to determine whether two objects are equal

ToString () method
     Public String toString () {        return getclass (). GetName () + "@" + integer.tohexstring (Hashcode ());    } 

Returns the string representation of the object, typically overriding the change method

Clone method
    protected native throws Clonenotsupportedexception;

Used to create and return a copy of this object, actually returning a reference to the object, pointing to the new clone object, which occupies a different memory space than the original object

Finalize () method
    protected void throws Throwable {}

This method is mainly related to garbage collection, we do not need to care about this method for the time being

Java source-object

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.