做网站和微信小程序,在线做网站大概多少钱,网站建设叁金手指花总1,6生肖竞猜网站建设为什么80%的码农都做不了架构师#xff1f; Object类 Object类是Java中所有类的父类#xff0c;没有Object类Java面向对象无从谈起。作为其他所有类的基类#xff0c;Object具有哪些属性和行为#xff0c;是Java语言设计背后的思维体现。 Object类位于java.… 为什么80%的码农都做不了架构师 Object类 Object类是Java中所有类的父类没有Object类Java面向对象无从谈起。作为其他所有类的基类Object具有哪些属性和行为是Java语言设计背后的思维体现。 Object类位于java.lang包中java.lang包包含着Java最基础和核心的类在编译时会自动导入。Object类没有定义属性一共有13个方法具体的类定义结构如下图 Object的作者unascribed未知不过贡献是有目共睹的 //说明源码中的注释已进行删减
package java.lang;/*** Class {code Object} is the root of the class hierarchy.* Every class has {code Object} as a superclass. All objects,* including arrays, implement the methods of this class.** author unascribed* see java.lang.Class* since JDK1.0*/
public class Object {private static native void registerNatives();static {registerNatives();}public final native Class? getClass();/**** return a hash code value for this object.* see java.lang.Object#equals(java.lang.Object)* see java.lang.System#identityHashCode*/public native int hashCode();/**** param obj the reference object with which to compare.* return {code true} if this object is the same as the obj* argument; {code false} otherwise.* see #hashCode()* see java.util.HashMap*/public boolean equals(Object obj) {return (this obj);}/**** return a clone of this instance.* throws CloneNotSupportedException if the objects class does not* support the {code Cloneable} interface. Subclasses* that override the {code clone} method can also* throw this exception to indicate that an instance cannot* be cloned.* see java.lang.Cloneable*/protected native Object clone() throws CloneNotSupportedException;/**** return a string representation of the object.*/public String toString() {return getClass().getName() Integer.toHexString(hashCode());}/*** Only one thread at a time can own an objects monitor.** throws IllegalMonitorStateException if the current thread is not* the owner of this objects monitor.* see java.lang.Object#notifyAll()* see java.lang.Object#wait()*/public final native void notify();/**** throws IllegalMonitorStateException if the current thread is not* the owner of this objects monitor.* see java.lang.Object#notify()* see java.lang.Object#wait()*/public final native void notifyAll();/*** param timeout the maximum time to wait in milliseconds.* throws IllegalArgumentException if the value of timeout is* negative.* throws IllegalMonitorStateException if the current thread is not* the owner of the objects monitor.* throws InterruptedException if any thread interrupted the* current thread before or while the current thread* was waiting for a notification. The iinterrupted* status/i of the current thread is cleared when* this exception is thrown.* see java.lang.Object#notify()* see java.lang.Object#notifyAll()*/public final native void wait(long timeout) throws InterruptedException;/**** param timeout the maximum time to wait in milliseconds.* param nanos additional time, in nanoseconds range* 0-999999.* throws IllegalArgumentException if the value of timeout is* negative or the value of nanos is* not in the range 0-999999.* throws IllegalMonitorStateException if the current thread is not* the owner of this objects monitor.* throws InterruptedException if any thread interrupted the* current thread before or while the current thread* was waiting for a notification. The iinterrupted* status/i of the current thread is cleared when* this exception is thrown.*/public final void wait(long timeout, int nanos) throws InterruptedException {if (timeout 0) {throw new IllegalArgumentException(timeout value is negative);}if (nanos 0 || nanos 999999) {throw new IllegalArgumentException(nanosecond timeout value out of range);}if (nanos 0) {timeout;}wait(timeout);}/**** throws IllegalMonitorStateException if the current thread is not* the owner of the objects monitor.* throws InterruptedException if any thread interrupted the* current thread before or while the current thread* was waiting for a notification. The iinterrupted* status/i of the current thread is cleared when* this exception is thrown.* see java.lang.Object#notify()* see java.lang.Object#notifyAll()*/public final void wait() throws InterruptedException {wait(0);}/*** throws Throwable the {code Exception} raised by this method* see java.lang.ref.WeakReference* see java.lang.ref.PhantomReference* jls 12.6 Finalization of Class Instances*/protected void finalize() throws Throwable { }
}根据源码的相关注释已经可以有一定的了解。具体不多赘述当然有一篇详细的文章可以参考 Java总结篇系列java.lang.Object 转载于:https://my.oschina.net/anlve/blog/909206