*/
package java.lang;
/**
-
Class {@code Object} is the root of the class hierarchy【类层次结构,等级】.
-
Every class has {@code Object} as a superclass. All objects,
-
including arrays, implement the methods of this class.
-
@author unascribed
-
@see java.lang.Class
-
@since JDK1.0
*/
public class Object {
private static native void registerNatives();
static {
registerNatives();
}
/**
-
Returns the runtime class of this {@code Object}. The returned
-
{@code Class} object is the object that is locked by {@code
-
static synchronized} methods of the represented class.
-
The actual result type is {@code Class<? extends |X|>}
-
where {@code |X|} is the erasure of the static type of the
-
expression on which {@code getClass} is called. For
-
example, no cast is required in this code fragment:
-
-
{@code Number n = 0; }
-
{@code Class<? extends Number> c = n.getClass(); }
-
@return The {@code Class} object that represents the runtime
-
class of this object.
-
@jls 15.8.2 Class Literals
*/
public final native Class<?> getClass(); //返回一个对象的运行时类,通过返回的类对象可以获取运行时类的相关属性和方法,就是java的反射机制
/**
-
Returns a hash code value for the object. This method is
-
supported for the benefit of hash tables such as those provided by
-
{@link java.util.HashMap}.
-
-
The general contract of {@code hashCode} is:
-
- Whenever it is invoked on the same object more than once during
-
an execution of a Java application, the {@code hashCode} method
-
must consistently return the same integer, provided no information
-
used in {@code equals} comparisons on the object is modified.
-
This integer need not remain consistent from one execution of an
-
application to another execution of the same application.
- If two objects are equal according to the {@code equals(Object)}
-
method, then calling the {@code hashCode} method on each of
-
the two objects must produce the same integer result.
- It is not required that if two objects are unequal
-
according to the {@link java.lang.Object#equals(java.lang.Object)}
-
method, then calling the {@code hashCode} method on each of the
-
two objects must produce distinct integer results. However, the
-
programmer should be aware that producing distinct integer results
-
for unequal objects may improve the performance of hash tables.
-
-
As much as is reasonably practical, the hashCode method defined by
-
class {@code Object} does return distinct integers for distinct
-
objects. (This is typically implemented by converting the internal
-
address of the object into an integer, but this implementation
-
technique is not required by the
-
Java™ programming language.)
-
@return a hash code value for this object.
-
@see java.lang.Object#equals(java.lang.Object)
-
@see java.lang.System#identityHashCode
*/
public native int hashCode(); //返回对象的散列码
/**
-
Indicates【表明】 whether some other object is “equal to” this one.
-
-
The {@code equals} method implements an equivalence relation
-
on non-null object references:
-
- It is reflexive: 【自反性】f
-