当前位置:网站首页>Object 类——万类之父
Object 类——万类之父
2022-06-29 10:38:00 【努 力 小 子】
Object 类是一个特殊的类,是所有类的父类。
正因为有了这层关系,Object类里的通用方法(函数)都是可以被子类使用的。
public final native Class<?> getClass()
//native方法,用于返回当前运行时对象的Class对象,使用了final关键字修饰,故不允许子类重写。
public native int hashCode()
//native方法,用于返回对象的哈希码,主要使用在哈希表中,比如JDK中的HashMap。
public boolean equals(Object obj)
//用于比较2个对象的内存地址是否相等,String类对该方法进行了重写用户比较字符串的值是否相等。
protected native Object clone() throws CloneNotSupportedException
//naitive方法,用于创建并返回当前对象的一份拷贝。一般情况下,对于任何对象 x,表达式 x.clone() != x 为true,x.clone().getClass() == x.getClass() 为true。Object本身没有实现Cloneable接口,所以不重写clone方法并且进行调用的话会发生CloneNotSupportedException异常。
public String toString()
//返回类的名字@实例的哈希码的16进制的字符串。建议Object所有的子类都重写这个方法。
public final native void notify()
//native方法,并且不能重写。唤醒一个在此对象监视器上等待的线程(监视器相当于就是锁的概念)。如果有多个线程在等待只会任意唤醒一个。
public final native void notifyAll()
//native方法,并且不能重写。跟notify一样,唯一的区别就是会唤醒在此对象监视器上等待的所有线程,而不是一个线程。
public final native void wait(long timeout) throws InterruptedException
//native方法,并且不能重写。暂停线程的执行。注意:sleep方法没有释放锁,而wait方法释放了锁 。timeout是等待时间。
public final void wait(long timeout, int nanos) throws InterruptedException
//多了nanos参数,这个参数表示额外时间(以毫微秒为单位,范围是 0-999999)。 所以超时的时间还需要加上nanos毫秒。
public final void wait() throws InterruptedException
//跟之前的2个wait方法一样,只不过该方法一直等待,没有超时时间这个概念
protected void finalize() throws Throwable {
}
//实例被垃圾回收器回收的时候触发的操作
边栏推荐
- Nuc980 open source project 16- start from SPI flash (w25q128)
- Graduation season · advanced technology Er - workers in the workplace
- Course design for the end of the semester: product sales management system based on SSM
- Self-Improvement! Junior college "counter attack" master of Zhejiang University, 3 SCI, and finally become a doctor of Tsinghua University!
- Nature | 全球海洋微生物组的生物合成潜力
- 软件工程导论——第五章——总体设计
- QT learning 11 string classes in QT
- Haitai Advanced Technology | application of privacy computing technology in medical data protection
- The use of Fibonacci sequence and bubble sort in C language
- What is the experience of working in an IT company in Japan?
猜你喜欢

How to test the performance of container platform, including stability, expansion efficiency and component performance

喜报|海泰方圆通过CMMI-3资质认证,研发能力获国际认可

math_ Mathematical expression & deformation of equation equation & accumulation of combined operation skills / means

Evaluation of IP location query interface Ⅱ
![[daily 3 questions (1)] judge the color of a grid on the chess board](/img/bd/064058f917554237b741795d405189.png)
[daily 3 questions (1)] judge the color of a grid on the chess board

Discussion on QT learning 10 message processing in QT

什么?漫画居然能免费看全本了,这还不学起来一起做省钱小能手
![Leetcode 535 encryption and decryption of tinyurl [map] the leetcode road of heroding](/img/76/709bbbbd8eb01f32683a96c4abddb9.png)
Leetcode 535 encryption and decryption of tinyurl [map] the leetcode road of heroding

Live broadcast by technical experts from China Kuwait Fangde: how to build a private cloud platform based on openstack and CEPH| Issue 27

(JS) filter out keys with value greater than 2 in the object
随机推荐
行业分析| 快对讲,楼宇对讲
2.8万字的Callable和Future面试知识点总结,看完我直接面进了字节跳动,原谅我有点飘了(下)
Adding sharding sphere5.0.0 sub tables to the ruoyi framework (adding custom sub table policies through SPI)
(JS) handwritten deep copy
多线程高并发服务器:3个问题
Pipeline aggregations管道聚合-Sibling-1
Limit introduction summary
(JS) pure function in array
Lizuofan, co-founder of nonconvex: Taking quantification as his lifelong career
毕业季·进击的技术er - 职场打工人
Live broadcast by technical experts from China Kuwait Fangde: how to build a private cloud platform based on openstack and CEPH| Issue 27
Spark - Task 与 Partition 一一对应与参数详解
(JS) array de duplication
ruoyi框架中添加sharding sphere5.0.0分表(通过spi添加自定义分表策略)
斐波那锲数列与冒泡排序法在C语言中的用法
QT learning 11 string classes in QT
Shell 引号和转义从来很少被人注意,但平时写脚本又经常用
Graduation season · advanced technology Er - workers in the workplace
又拍云 Redis 的改进之路
Pipeline aggregations pipeline aggregations - parent-2