Java Object Class Learning Notes

Source: Internet
Author: User

Take a look at some instructions for the API documentation

public class Object

Class is the root of the Object class hierarchy. Every class has as Object a superclass. All objects, including arrays, implement the methods of this class.

      • Since:

      • JDK1.0

From the JDK1.0 of the already existing Senator class, the root of the class structure, the parent class of all classes, all classes implement the method of this class, including the arrays. Special emphasis was placed on arrays.

Constructor Summary

Constructors Constructor and Description

Object ()

Introduction to construction methods.

Modifier and Type Method and Description

Protected Object Clone ()

Creates and returns a copy of this object.

Clone method, which returns the copy of an object

Boolean equals (Object obj)

Indicates whether some other object are "equal to" this one.

The Equals method, which belongs to the most primitive equals, determines whether an object equal to another object

protected void Finalize ()

Called by the garbage collector on a object when garbage collection determines that there is no more references to the O Bject.

when confirming that the object does not have any references, call the famous GC, garbage collector, on an object,

Class<?> GetClass ()

Returns the runtime class of this Object.

Returns the run-time class of this object

int Hashcode ()

Returns a hash code value for the object.

The famous Hashcode method, returns the hash code of an object, note that it is a plastic int

void Notify ()

Wakes up a single thread, that's waiting on this object ' s monitor.

Wakes up a monitoring thread that is waiting for the current object, typically translated as a wake-up thread

void Notifyall ()

Wakes up all threads is waiting on this object ' s monitor.

Wakes up all the monitoring threads that are waiting on the current object,

String toString ()

Returns a string representation of the object.

The famous ToString () method, which returns a string representation of the object

void Wait ()

Causes the current thread to wait until another thread invokes the Notify () method or the Notifyall () method for this Obje Ct.

The famous wait method, interview often people ask him and sleep method difference. , let the current thread wait until there are other threads calling the object's notify () method or notifyall ()

void wait (long timeout)

Causes the current thread to wait until either another thread invokes the Notify () method or the Notifyall () method for th is object, or a specified amount of time have elapsed.

Lets the current thread wait for another thread to call the notify () method or the Notifyall () method, or the specified time to run. So what is the specified time to run?

void Wait (long timeout, int nanos)

Causes the current thread to wait until another thread invokes the Notify () method or the Notifyall () method for this Obje CT, or some other thread interrupts the current thread, or a certain amount of real time have elapsed.

let the current thread wait for another thread to call Notify () method or the Notifyall () method, or another thread that interrupts the current thread, or the specified time to run


Java Object Class Learning Notes

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.