Object类中有哪些方法

Object源码

publicclassObject {

privatestaticnativevoidregisterNatives();

static{

registerNatives();

}

publicfinalnativeClass getClass();

publicnativeinthashCode();

publicbooleanequals(Object obj) {

return(this== obj);

}

protectednativeObject clone()throwsCloneNotSupportedException;

publicString toString() {

returngetClass().getName() +"@"+ Integer.toHexString(hashCode());

}

publicfinalnativevoidnotify();

publicfinalnativevoidnotifyAll();

publicfinalnativevoidwait(longtimeout)throwsInterruptedException;

publicfinalvoidwait(longtimeout,intnanos)throwsInterruptedException {

if(timeout <0) {

thrownewIllegalArgumentException("timeout value is negative");

}

if(nanos <0|| nanos >999999) {

thrownewIllegalArgumentException(

"nanosecond timeout value out of range");

}

if(nanos >=500000|| (nanos !=0&& timeout ==0)) {

timeout++;

}

wait(timeout);

}

publicfinalvoidwait()throwsInterruptedException {

wait(0);

}

protectedvoidfinalize()throwsThrowable { }

}


下面是这些方法:

registerNatives()

getClass()

hashCode()

equals(Object obj)

clone()

toString()

notify()

notifyAll()

wait(long timeout)

wait(long timeout, int nanos)

wait()

finalize()

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容