Java Object类方法
2016-04-13 21:21
162 查看
Java 8中
package java.lang; public class Object { private static native void registerNatives(); static { registerNatives(); } public final native Class<?> getClass(); public native int hashCode(); public boolean equals(Object obj) { return (this == obj); } protected native Object clone() throws CloneNotSupportedException; public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); } public final native void notify(); public final native void notifyAll(); public final native void wait(long timeout) throws InterruptedException; 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); } public final void wait() throws InterruptedException { wait(0); } protected void finalize() throws Throwable { } }
protected Object clone()创建并返回此对象的一个副本。
boolean equals(Object obj)指示其他某个对象是否与此对象“相等”。
protected void finalize()当垃圾回收器确定不存在对该对象的更多引用时,由对象的垃圾回收器调用此方法。
Class<?> getClass()返回此 Object 的运行时类。
int hashCode()返回该对象的哈希码值。
void notify()唤醒在此对象监视器上等待的单个线程。
void notifyAll()唤醒在此对象监视器上等待的所有线程。
String toString()返回该对象的字符串表示。
void wait()在其他线程调用此对象的 notify() 方法或 notifyAll() 方法前,导致当前线程等待。
void wait(long timeout)在其他线程调用此对象的 notify() 方法或 notifyAll() 方法,或者超过指定的时间量前,导致当前线程等待。
void wait(long timeout, int nanos)在其他线程调用此对象的 notify() 方法或 notifyAll() 方法,或者其他某个线程中断当前线程,或者已超过某个实际时间量前,导致当前线程等待。
相关文章推荐
- iOS开发Objective-C编码规范
- Java 类型转换以及Object转成其他类型
- Objective-C第2版第9章 内存管理
- Objective-C第2版第6章源文件组织学习记录
- 警告:Could not resolve external type c:objc(cs)NSObject
- nil / Nil / NULL / NSNull
- Object类型
- JSONObject与JSONArray的使用
- Java之—— java mail 发送邮件 no object DCH for MIME type multipart/mixed 之正解
- Objective-C与Java面向对象对比学习(一)
- 16进制颜色表
- The Object interface&The QUnit interface
- ObjectOutputStream 和 ObjectInputStream的使用
- ObjectOutputStream 和 ObjectInputStream的使用
- ObjectOutputStream 和 ObjectInputStream的使用
- Objective-c与javascript交互[详细解读2]
- PHP中把stdClass Object转array的几个方法
- 4.Object Types
- 《Effective Objective-C 2.0:编写高质量iOS与OS X代码的52个有效方法》 笔记2 多用字面量语法,少用与之等价的方法
- 《Effective Objective-C 2.0:编写高质量iOS与OS X代码的52个有效方法》 笔记1