📄 method.html
字号:
<DD>Returns the name of the method represented by this <code>Method</code> object, as a <code>String</code>.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../java/lang/reflect/Member.html#getName()">getName</A></CODE> in interface <CODE><A HREF="../../../java/lang/reflect/Member.html">Member</A></CODE></DL></DD></DL><HR><A NAME="getModifiers()"><!-- --></A><H3>getModifiers</H3><PRE>public int <B>getModifiers</B>()</PRE><DL><DD>Returns the Java language modifiers for the method represented by this <code>Method</code> object, as an integer. The <code>Modifier</code> class should be used to decode the modifiers.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../java/lang/reflect/Member.html#getModifiers()">getModifiers</A></CODE> in interface <CODE><A HREF="../../../java/lang/reflect/Member.html">Member</A></CODE></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../../java/lang/reflect/Modifier.html"><CODE>Modifier</CODE></A></DL></DD></DL><HR><A NAME="getReturnType()"><!-- --></A><H3>getReturnType</H3><PRE>public <A HREF="../../../java/lang/Class.html">Class</A> <B>getReturnType</B>()</PRE><DL><DD>Returns a <code>Class</code> object that represents the formal return type of the method represented by this <code>Method</code> object.<DD><DL></DL></DD></DL><HR><A NAME="getParameterTypes()"><!-- --></A><H3>getParameterTypes</H3><PRE>public <A HREF="../../../java/lang/Class.html">Class</A>[] <B>getParameterTypes</B>()</PRE><DL><DD>Returns an array of <code>Class</code> objects that represent the formal parameter types, in declaration order, of the method represented by this <code>Method</code> object. Returns an array of length 0 if the underlying method takes no parameters.<DD><DL></DL></DD></DL><HR><A NAME="getExceptionTypes()"><!-- --></A><H3>getExceptionTypes</H3><PRE>public <A HREF="../../../java/lang/Class.html">Class</A>[] <B>getExceptionTypes</B>()</PRE><DL><DD>Returns an array of <code>Class</code> objects that represent the types of the exceptions declared to be thrown by the underlying method represented by this <code>Method</code> object. Returns an array of length 0 if the method declares no exceptions in its <code>throws</code> clause.<DD><DL></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>Compares this <code>Method</code> against the specified object. Returns true if the objects are the same. Two <code>Methods</code> are the same if they were declared by the same class and have the same name and formal parameter types and return type.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/lang/Object.html#equals(java.lang.Object)">equals</A></CODE> in class <CODE><A HREF="../../../java/lang/Object.html">Object</A></CODE></DL></DD><DD>Following copied from class: <CODE>java.lang.Object</CODE></DD><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="hashCode()"><!-- --></A><H3>hashCode</H3><PRE>public int <B>hashCode</B>()</PRE><DL><DD>Returns a hashcode for this <code>Method</code>. The hashcode is computed as the exclusive-or of the hashcodes for the underlying method's declaring class name and the method's name.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/lang/Object.html#hashCode()">hashCode</A></CODE> in class <CODE><A HREF="../../../java/lang/Object.html">Object</A></CODE></DL></DD><DD>Following copied from class: <CODE>java.lang.Object</CODE></DD><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>Object.equals(java.lang.Object)</CODE></A>, <A HREF="../../../java/util/Hashtable.html"><CODE>Hashtable</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 describing this <code>Method</code>. The string is formatted as the method access modifiers, if any, followed by the method return type, followed by a space, followed by the class declaring the method, followed by a period, followed by the method name, followed by a parenthesized, comma-separated list of the method's formal parameter types. If the method throws checked exceptions, the parameter list is followed by a space, followed by the word throws followed by a comma-separated list of the thrown exception types. For example: <pre> public boolean java.lang.Object.equals(java.lang.Object) </pre> <p>The access modifiers are placed in canonical order as specified by "The Java Language Specification". This is <tt>public</tt>, <tt>protected</tt> or <tt>private</tt> first, and then other modifiers in the following order: <tt>abstract</tt>, <tt>static</tt>, <tt>final</tt>, <tt>synchronized</tt> <tt>native</tt>.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../../java/lang/Object.html">Object</A></CODE></DL></DD><DD>Following copied from class: <CODE>java.lang.Object</CODE></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of the object.</DL></DD></DL><HR><A NAME="invoke(java.lang.Object, java.lang.Object[])"><!-- --></A><H3>invoke</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A> <B>invoke</B>(<A HREF="../../../java/lang/Object.html">Object</A> obj, <A HREF="../../../java/lang/Object.html">Object</A>[] args) throws <A HREF="../../../java/lang/IllegalAccessException.html">IllegalAccessException</A>, <A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A>, <A HREF="../../../java/lang/reflect/InvocationTargetException.html">InvocationTargetException</A></PRE><DL><DD>Invokes the underlying method represented by this <code>Method</code> object, on the specified object with the specified parameters. Individual parameters are automatically unwrapped to match primitive formal parameters, and both primitive and reference parameters are subject to widening conversions as necessary. The value returned by the underlying method is automatically wrapped in an object if it has a primitive type. <p>Method invocation proceeds with the following steps, in order: <p>If the underlying method is static, then the specified <code>obj</code> argument is ignored. It may be null. <p>Otherwise, the method is an instance method. If the specified object argument is null, the invocation throws a <code>NullPointerException</code>. Otherwise, if the specified object argument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof) the invocation throws an <code>IllegalArgumentException</code>. <p>If this <code>Method</code> object enforces Java language access control and the underlying method is inaccessible, the invocation throws an <code>IllegalAccessException</code>. <p>If the number of actual parameters supplied via <code>args</code> is different from the number of formal parameters required by the underlying method, the invocation throws an <code>IllegalArgumentException</code>. <p>For each actual parameter in the supplied <code>args</code> array: <p>If the corresponding formal parameter has a primitive type, an unwrapping conversion is attempted to convert the object value to a value of a primitive type. If this attempt fails, the invocation throws an <code>IllegalArgumentException</code>. <p>If, after possible unwrapping, the parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion, the invocation throws an <code>IllegalArgumentException</code>. <p>If the underlying method is an instance method, it is invoked using dynamic method lookup as documented in The Java Language Specification, section 15.11.4.4; in particular, overriding based on the runtime type of the target object will occur. <p>If the underlying method is static, the class that declared the method is initialized if it has not already been initialized. The underlying method is invoked directly. <p>Control transfers to the invoked method. If the method completes abruptly by throwing an exception, the exception is placed in an <code>InvocationTargetException</code> and thrown in turn to the caller of invoke. <p>If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is first appropriately wrapped in an object. If the underlying method return type is void, the invocation returns null.<DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalAccessException.html">IllegalAccessException</A></CODE> - if the underlying method is inaccessible.<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the number of actual and formal parameters differ, or if an unwrapping conversion fails.<DD><CODE><A HREF="../../../java/lang/reflect/InvocationTargetException.html">InvocationTargetException</A></CODE> - if the underlying method throws an exception.<DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if the specified object is null and the method is an instance method.<DD><CODE><A HREF="../../../java/lang/ExceptionInInitializerError.html">ExceptionInInitializerError</A></CODE> - if the initialization provoked by this method fails.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Method.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../java/lang/reflect/Field.html"><B>PREV CLASS</B></A> <A HREF="../../../java/lang/reflect/Modifier.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Method.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -