码迷,mamicode.com
首页 > 其他好文 > 详细

object类

时间:2018-04-18 23:38:05      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:strong   obj   nal   UI   返回   方法   void   hashcode   finalize   

 

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

 



 


object类

标签:strong   obj   nal   UI   返回   方法   void   hashcode   finalize   

原文地址:https://www.cnblogs.com/leo9257/p/8877967.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!