class.html
来自「API資料大全」· HTML 代码 · 共 1,325 行 · 第 1/5 页
HTML
1,325 行
B byte C char D double F float I int J long L<i>classname;</i> class or interface S short Z boolean </pre></blockquote> The class or interface name <tt><i>classname</i></tt> is given in fully qualified form as shown in the example above.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the fully qualified name of the class or interface represented by this object.</DL></DD></DL><HR><A NAME="getClassLoader()"><!-- --></A><H3>getClassLoader</H3><PRE>public <A HREF="../../java/lang/ClassLoader.html">ClassLoader</A> <B>getClassLoader</B>()</PRE><DL><DD>Returns the class loader for the class. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader. <p> If a security manager is present, and the caller's class loader is not null and the caller's class loader is not the same as or an ancestor of the class loader for the class whose class loader is requested, then this method calls the security manager's <code>checkPermission</code> method with a <code>RuntimePermission("getClassLoader")</code> permission to ensure it's ok to access the class loader for the class. <p>If this object represents a primitive type or void, null is returned.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the class loader that loaded the class or interface represented by this object.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if a security manager exists and its <code>checkPermission</code> method denies access to the class loader for the class.<DT><B>See Also: </B><DD><A HREF="../../java/lang/ClassLoader.html"><CODE>ClassLoader</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPermission(java.security.Permission)"><CODE>SecurityManager.checkPermission(java.security.Permission)</CODE></A>, <A HREF="../../java/lang/RuntimePermission.html"><CODE>RuntimePermission</CODE></A></DL></DD></DL><HR><A NAME="getSuperclass()"><!-- --></A><H3>getSuperclass</H3><PRE>public <A HREF="../../java/lang/Class.html">Class</A> <B>getSuperclass</B>()</PRE><DL><DD>Returns the <code>Class</code> representing the superclass of the entity (class, interface, primitive type or void) represented by this <code>Class</code>. If this <code>Class</code> represents either the <code>Object</code> class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the <code>Class</code> object representing the <code>Object</code> class is returned.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the superclass of the class represented by this object.</DL></DD></DL><HR><A NAME="getPackage()"><!-- --></A><H3>getPackage</H3><PRE>public <A HREF="../../java/lang/Package.html">Package</A> <B>getPackage</B>()</PRE><DL><DD>Gets the package for this class. The class loader of this class is used to find the package. If the class was loaded by the bootstrap class loader the set of packages loaded from CLASSPATH is searched to find the package of the class. Null is returned if no package object was created by the class loader of this class. <p> Packages have attributes for versions and specifications only if the information was defined in the manifests that accompany the classes, and if the class loader created the package instance with the attributes from the manifest.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the package of the class, or null if no package information is available from the archive or codebase.</DL></DD></DL><HR><A NAME="getInterfaces()"><!-- --></A><H3>getInterfaces</H3><PRE>public <A HREF="../../java/lang/Class.html">Class</A>[] <B>getInterfaces</B>()</PRE><DL><DD>Determines the interfaces implemented by the class or interface represented by this object. <p> If this object represents a class, the return value is an array containing objects representing all interfaces implemented by the class. The order of the interface objects in the array corresponds to the order of the interface names in the <code>implements</code> clause of the declaration of the class represented by this object. For example, given the declaration: <blockquote><pre> class Shimmer implements FloorWax, DessertTopping { ... } </pre></blockquote> suppose the value of <code>s</code> is an instance of <code>Shimmer</code>; the value of the expression: <blockquote><pre> s.getClass().getInterfaces()[0] </pre></blockquote> is the <code>Class</code> object that represents interface <code>FloorWax</code>; and the value of: <blockquote><pre> s.getClass().getInterfaces()[1] </pre></blockquote> is the <code>Class</code> object that represents interface <code>DessertTopping</code>. <p> If this object represents an interface, the array contains objects representing all interfaces extended by the interface. The order of the interface objects in the array corresponds to the order of the interface names in the <code>extends</code> clause of the declaration of the interface represented by this object. <p> If this object represents a class or interface that implements no interfaces, the method returns an array of length 0. <p> If this object represents a primitive type or void, the method returns an array of length 0.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>an array of interfaces implemented by this class.</DL></DD></DL><HR><A NAME="getComponentType()"><!-- --></A><H3>getComponentType</H3><PRE>public <A HREF="../../java/lang/Class.html">Class</A> <B>getComponentType</B>()</PRE><DL><DD>Returns the <code>Class</code> representing the component type of an array. If this class does not represent an array class this method returns null.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the <code>Class</code> representing the component type of this class if this class is an array<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/reflect/Array.html"><CODE>Array</CODE></A></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 this class or interface, encoded in an integer. The modifiers consist of the Java Virtual Machine's constants for <code>public</code>, <code>protected</code>, <code>private</code>, <code>final</code>, <code>static</code>, <code>abstract</code> and <code>interface</code>; they should be decoded using the methods of class <code>Modifier</code>. <p> If the underlying class is an array class, then its <code>public</code>, <code>private</code> and <code>protected</code> modifiers are the same as those of its component type. If this <code>Class</code> represents a primitive type or void, its <code>public</code> modifier is always <code>true</code>, and its <code>protected</code> and <code>private</code> modifers are always <code>false</code>. If this object represents an array class, a primitive type or void, then its <code>final</code> modifier is always <code>true</code> and its interface modifer is always <code>false</code>. The values of its other modifiers are not determined by this specification. <p> The modifier encodings are defined in <em>The Java Virtual Machine Specification</em>, table 4.1.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the <code>int</code> representing the modifiers for this class<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/reflect/Modifier.html"><CODE>Modifier</CODE></A></DL></DD></DL><HR><A NAME="getSigners()"><!-- --></A><H3>getSigners</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A>[] <B>getSigners</B>()</PRE><DL><DD>Gets the signers of this class.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the signers of this class, or null if there are no signers. In particular, this method returns null if this object represents a primitive type or void.<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="getDeclaringClass()"><!-- --></A><H3>getDeclaringClass</H3><PRE>public <A HREF="../../java/lang/Class.html">Class</A> <B>getDeclaringClass</B>()</PRE><DL><DD>If the class or interface represented by this <code>Class</code> object is a member of another class, returns the <code>Class</code> object representing the class in which it was declared. This method returns null if this class or interface is not a member of any other class. If this <code>Class</code> object represents an array class, a primitive type, or void,then this method returns null.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the declaring class for this class<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="getClasses()"><!-- --></A><H3>getClasses</H3><PRE>public <A HREF="../../java/lang/Class.html">Class</A>[] <B>getClasses</B>()</PRE><DL><DD>Returns an array containing <code>Class</code> objects representing all the public classes and interfaces that are members of the class represented by this <code>Class</code> object. This includes public class and interface members inherited from superclasses and public class and interface members declared by the class. This method returns an array of length 0 if this <code>Class</code> object has no public member classes or interfaces. This method also returns an array of length 0 if this <code>Class</code> object represents a primitive type, an array class, or void. <p>For this class and each of its superclasses, the following security checks are performed: If there is a security manager, the security manager's <code>checkMemberAccess</code> method is called with <code>this</code> and <code>Member.PUBLIC</code> as its arguments, where <code>this</code> is this class or the superclass whose members are being determined. If the class is in a package, then the security manager's <code>checkPackageAccess</code> method is also called with the package name as its argument. Either of these calls could result in a SecurityException.<DD><DL></DL></DD><DD><DL>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?