zoukankan      html  css  js  c++  java
  • 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

    方法

    该方法用于释放资源。因为无法确定该方法什么时候被调用,很少使用

  • 相关阅读:
    Ueeidor 使用
    springMvc 拦截器
    redis 设置密码
    freemarker 定义公共header
    freemarker macro 使用
    freemarker ! 用法
    Android 远程连接数据库。。。。。
    Android Studio 配置
    Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结
    表单,table的css
  • 原文地址:https://www.cnblogs.com/luliang888/p/10902493.html
Copyright © 2011-2022 走看看