Object类常用方法
| No. | 方法名称 | 类型 | 描述 | 
| 1 | public final Class<?> getClass() | 方法 | final方法,获得运行时的Class类型 | 
| 2 | public int hashCode() | 方法 | 返回其所在对象的物理地址(哈希码值),常会和equals方法同时重写,确保相等的两个对象是相等的 | 
| 3 | public boolean equals(Object obj) | 方法 | 用于比较对象是否相等,比较的是两个对象的地址 | 
| 4 | protected Object clone() throws CloneNotSupportedException | 方法 | 实现对象的浅复制,只有实现了Cloneable接口才可以调用该方法,否则抛出CloneNotSupportedException异常 | 
| 5 | public String toString() | 方法 | 打印对象时被调用,将对象信息变为字符串返回,默认输出对象地址 | 
| 6 | public final void notify() | 方法 | 该方法唤醒在该对象上等待的某个线程 | 
| 7 | public final void notifyAll() | 方法 | 该方法唤醒在该对象上等待的所有线程 | 
| 8 | public final void wait() throws InterruptedException | 方法 | wait方法就是使当前线程等待该对象的锁 | 
| 9 | @Deprecated(since="9") protected void finalize() throws Throwable | 方法 | 该方法用于释放资源。因为无法确定该方法什么时候被调用,很少使用 | 
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号