📄 object.html
字号:
object is the object that is locked by <tt>static synchronized</tt> methods of the represented class.<DD><DL><DT><B>Returns:</B><DD>the object of type <code>Class</code> that represents the runtime class of the object.</DL></DD></DL><HR><A NAME="hashCode()"><!-- --></A><H3>hashCode</H3><PRE>public int <B>hashCode</B>()</PRE><DL><DD>Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by <code>java.util.Hashtable</code>. <p> The general contract of <code>hashCode</code> is: <ul> <li>Whenever it is invoked on the same object more than once during an execution of a Java application, the <tt>hashCode</tt> method must consistently return the same integer, provided no information used in <tt>equals</tt> 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. <li>If two objects are equal according to the <tt>equals(Object)</tt> method, then calling the <code>hashCode</code> method on each of the two objects must produce the same integer result. <li>It is <em>not</em> required that if two objects are unequal according to the <A HREF="../../java/lang/Object.html#equals(java.lang.Object)"><CODE>equals(java.lang.Object)</CODE></A> method, then calling the <tt>hashCode</tt> 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 hashtables. </ul> <p> As much as is reasonably practical, the hashCode method defined by class <tt>Object</tt> 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<font size="-2"><sup>TM</sup></font> programming language.)<DD><DL><DT><B>Returns:</B><DD>a hash code value for this object.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Object.html#equals(java.lang.Object)"><CODE>equals(java.lang.Object)</CODE></A>, <A HREF="../../java/util/Hashtable.html"><CODE>Hashtable</CODE></A></DL></DD></DL><HR><A NAME="equals(java.lang.Object)"><!-- --></A><H3>equals</H3><PRE>public boolean <B>equals</B>(<A HREF="../../java/lang/Object.html">Object</A> obj)</PRE><DL><DD>Indicates whether some other object is "equal to" this one. <p> The <code>equals</code> method implements an equivalence relation: <ul> <li>It is <i>reflexive</i>: for any reference value <code>x</code>, <code>x.equals(x)</code> should return <code>true</code>. <li>It is <i>symmetric</i>: for any reference values <code>x</code> and <code>y</code>, <code>x.equals(y)</code> should return <code>true</code> if and only if <code>y.equals(x)</code> returns <code>true</code>. <li>It is <i>transitive</i>: for any reference values <code>x</code>, <code>y</code>, and <code>z</code>, if <code>x.equals(y)</code> returns <code>true</code> and <code>y.equals(z)</code> returns <code>true</code>, then <code>x.equals(z)</code> should return <code>true</code>. <li>It is <i>consistent</i>: for any reference values <code>x</code> and <code>y</code>, multiple invocations of <tt>x.equals(y)</tt> consistently return <code>true</code> or consistently return <code>false</code>, provided no information used in <code>equals</code> comparisons on the object is modified. <li>For any non-null reference value <code>x</code>, <code>x.equals(null)</code> should return <code>false</code>. </ul> <p> The <tt>equals</tt> method for class <code>Object</code> implements the most discriminating possible equivalence relation on objects; that is, for any reference values <code>x</code> and <code>y</code>, this method returns <code>true</code> if and only if <code>x</code> and <code>y</code> refer to the same object (<code>x==y</code> has the value <code>true</code>).<DD><DL><DT><B>Parameters:</B><DD><CODE>obj</CODE> - the reference object with which to compare.<DT><B>Returns:</B><DD><code>true</code> if this object is the same as the obj argument; <code>false</code> otherwise.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Boolean.html#hashCode()"><CODE>Boolean.hashCode()</CODE></A>, <A HREF="../../java/util/Hashtable.html"><CODE>Hashtable</CODE></A></DL></DD></DL><HR><A NAME="clone()"><!-- --></A><H3>clone</H3><PRE>protected <A HREF="../../java/lang/Object.html">Object</A> <B>clone</B>() throws <A HREF="../../java/lang/CloneNotSupportedException.html">CloneNotSupportedException</A></PRE><DL><DD>Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object <tt>x</tt>, the expression: <blockquote> <pre> x.clone() != x</pre></blockquote> will be true, and that the expression: <blockquote> <pre> x.clone().getClass() == x.getClass()</pre></blockquote> will be <tt>true</tt>, but these are not absolute requirements. While it is typically the case that: <blockquote> <pre> x.clone().equals(x)</pre></blockquote> will be <tt>true</tt>, this is not an absolute requirement. Copying an object will typically entail creating a new instance of its class, but it also may require copying of internal data structures as well. No constructors are called. <p> The method <tt>clone</tt> for class <tt>Object</tt> performs a specific cloning operation. First, if the class of this object does not implement the interface <tt>Cloneable</tt>, then a <tt>CloneNotSupportedException</tt> is thrown. Note that all arrays are considered to implement the interface <tt>Cloneable</tT>. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation. <p> The class <tt>Object</tt> does not itself implement the interface <tt>Cloneable</tt>, so calling the <tt>clone</tt> method on an object whose class is <tt>Object</tt> will result in throwing an exception at run time. The <tt>clone</tt> method is implemented by the class <tt>Object</tt> as a convenient, general utility for subclasses that implement the interface <tt>Cloneable</tt>, possibly also overriding the <tt>clone</tt> method, in which case the overriding definition can refer to this utility definition by the call: <blockquote> <pre> super.clone()</pre></blockquote><DD><DL><DT><B>Returns:</B><DD>a clone of this instance.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/CloneNotSupportedException.html">CloneNotSupportedException</A></CODE> - if the object's class does not support the <code>Cloneable</code> interface. Subclasses that override the <code>clone</code> method can also throw this exception to indicate that an instance cannot be cloned.<DD><CODE><A HREF="../../java/lang/OutOfMemoryError.html">OutOfMemoryError</A></CODE> - if there is not enough memory.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Cloneable.html"><CODE>Cloneable</CODE></A></DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Returns a string representation of the object. In general, the <code>toString</code> method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. <p> The <code>toString</code> method for class <code>Object</code> returns a string consisting of the name of the class of which the object is an instance, the at-sign character `<code>@</code>', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: <blockquote> <pre> getClass().getName() + '@' + Integer.toHexString(hashCode()) </pre></blockquote><DD><DL><DT><B>Returns:</B><DD>a string representation of the object.</DL></DD></DL><HR><A NAME="notify()"><!-- --></A><H3>notify</H3><PRE>public final void <B>notify</B>()</PRE><DL><DD>Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the <code>wait</code> methods. <p> The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object. <p> This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways: <ul> <li>By executing a synchronized instance method of that object. <li>By executing the body of a <code>synchronized</code> statement that synchronizes on the object. <li>For objects of type <code>Class,</code> by executing a synchronized static method of that class. </ul> <p> Only one thread at a time can own an object's monitor.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalMonitorStateException.html">IllegalMonitorStateException</A></CODE> - if the current thread is not the owner of this object's monitor.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Object.html#notifyAll()"><CODE>notifyAll()</CODE></A>, <A HREF="../../java/lang/Object.html#wait()"><CODE>wait()</CODE></A></DL></DD></DL><HR><A NAME="notifyAll()"><!-- --></A><H3>notifyAll</H3><PRE>public final void <B>notifyAll</B>()</PRE><DL><DD>Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the <code>wait</code> methods. <p> The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object. <p> This method should only be called by a thread that is the owner of this object's monitor. See the <code>notify</code> method for a description of the ways in which a thread can become the owner of a monitor.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalMonitorStateException.html">IllegalMonitorStateException</A></CODE> - if the current thread is not the owner of this object's monitor.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Object.html#notify()"><CODE>notify()</CODE></A>, <A HREF="../../java/lang/Object.html#wait()"><CODE>wait()</CODE></A></DL></DD></DL><HR><A NAME="wait(long)"><!-- --></A><H3>wait</H3><PRE>public final void <B>wait</B>(long timeout) throws <A HREF="../../java/lang/InterruptedException.html">InterruptedException</A></PRE><DL><DD>Causes current thread to wait until either another thread invokes the <A HREF="../../java/lang/Object.html#notify()"><CODE>notify()</CODE></A> method or the <A HREF="../../java/lang/Object.html#notifyAll()"><CODE>notifyAll()</CODE></A> method for this object, or a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -