所有类的基类——Object
来源:互联网 发布:不基于比较的排序算法 编辑:程序博客网 时间:2024/05/16 17:23
Object
public class Object
java.lang.ObjectClass Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.
Object类是类层次结构中的根,每个类的父类都是Object类。所有对象,包括数组,都实现了这个类的方法。
Summary
Public constructors公共构造器
Object() ;
Public methods公共方法
boolean
equals(Object obj)
Indicates whether some other object is "equal to" this one.
(判断其他对象和这个对象是否相等) final Class<?>
getClass()
Returns the runtime class of this Object.
(返回运行时的类名) int
hashCode()
Returns a hash code value for the object.
(返回次对象的哈希代码值) final void
notify()
Wakes up a single thread that is waiting on this object's monitor.
(唤醒在该对象的监视器上等待的单个线程) final void
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
(唤醒在该对象的监视器上等待的所有线程) String
toString()
Returns a string representation of the object.
(返回该对象的字符串表达形式) final void
wait(long millis, int nanos)
Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
(让当前线程等待直到另一个线程调用了此对象的notify()
或notifyAll()
方法,或者其他某个线程中断了当前线程,或者过去了一定的时间) final void
wait(long millis)
Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.
(让当前线程等待直到另一个线程调用了此对象的notify()
或notifyAll()
方法,或者过去了一定的时间) final void
wait()
Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
(让当前线程等待直到另一个线程调用了此对象的notify()
或notifyAll()
方法)Protected methods
Object
clone()
Creates and returns a copy of this object.
(创建并返回此对象的副本) void
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
(当垃圾回收器确定该对象没有被引用时,调用此方法)Public methods方法简介
equals
boolean equals (Object obj)
Indicates whether some other object is “equal to” this one.
判断其他对象和这个对象是否相等。
The equals method implements an equivalence relation on non-null object references:
It is reflexive: for any non-null reference value x, x.equals(x) should return true.
It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
For any non-null reference value x, x.equals(null) should return false.
相等方法在非空对象引用上实现等价关系:
自反性:对于任何非空引用值x,x.equals(x)返回true;
对称性:对于任何非空引用值x和y,当且仅当y.equals(x)返回true的时候,x.equals(y)返回true;
传递性:对于任何非空引用值x、y和z,如果x.equals(y)返回true,y.equals(z)返回true,那么x.equals(z)也返回true;
一致性:对于任何非空引用值x和y,如果这两个对象都没有被修改,那么多次调用x.equals(y)会始终返回true或false;
对于任何非空引用值,x.equals(null)的返回值是false。
The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).
equals()方法是Object类中实现了最有辨别能力的最合理的等价关系。也就是说,对于任何非空引用值x和y,当x和y指向同一个对象的时候(x == y返回true),该方法返回true。
Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.
请注意为了保持hashCode方法的一致性,只要重写equals方法的时候,就必须要重写hanshCode方法,即相等的对象必须具有相等的哈希值。
obj
Object: the reference object with which to compare.
(对象:用来进行比较的对象)boolean
true if this object is the same as the obj argument; false otherwise.
(如果这个对象和传入的对象是相等的,返回true否则返回false)- 所有类的基类——Object
- 类Object的所有方法
- 类Object---所有对象的基类 简介
- 所有类的超类:Object类
- JAVA所有类的父类,鼻祖Object类源码
- 5.2 Object类,所有类的超类
- JAVA核心技术 第五章 Object 所有类的超类
- Java中所有类的超类Object
- Java实践(四)----所有类的祖宗Object
- QObject是QT所有类的基类,QObject是Qt Object Model的核心
- java—Object类
- 类的鼻祖—Object类
- 我的java学习笔记(9)关于Object:所有类的超类
- Object(所有类的超类)一些有用的方法讲解与实例演示
- Object所有类的超类之几个方法详析
- java:所有东西都是对象,所以根类就是Object
- 【Object-C】Object-C 的包装类
- Java——object类
- Jquery清空div内容
- 字母打印机 循环中标记变量的更改
- SPRING中的线程池ThreadPoolTaskExecutor
- html文档包含另一个html
- android-24中DatagramSocket的坑,以及synchronized的用法详解
- 所有类的基类——Object
- 读取Oracle的指定行
- LTE资源调度(7)-DRX不连续接收(1)
- java中的匿名内部类总结
- Winform右键单击单元格,弹出菜单
- 1.1数据结构->线性表->顺序表
- eclipse下debug模式不能正常运作的解决方法
- jquery对象以及方法总结
- RxJava的几个操作符和应用场景