object类

 

java.lang.Object

Object 是类层次结构的根类。每个类都使用 Object 作为超类。所有对象(包括数组)都实现这个类的方法。

1.object部分方法简介

1>public boolean equals(Object obj)
指示其他某个对象是否与此对象“相等”。
2>
protected void finalize()
                 throws Throwable
当垃圾回收器确定不存在对该对象的更多引用时,由对象的垃圾回收器调用此方法。
子类重写 finalize 方法,以配置系统资源或执行其他清除。
3>
public int hashCode()
返回该对象的哈希码值。
eg:StringBuffer leo9257 = new StringBuffer("nanjing...guiyang2009");
  System.out.println(leo9257.hashCode());//366712642
4>public String toString()
  
class Student{
    
}

public class Object {
    public static void main(String[] args) {
        
        Student a = new Student();
        System.out.println(a);//cn.jsti.gy.day13.Student@15db9742
        System.out.println(a.hashCode());//366712642
        System.out.println(a.toString());//cn.jsti.gy.day13.Student@15db9742

 



 


posted on 2018-04-18 22:11  长空剑使  阅读(132)  评论(0编辑  收藏  举报