Class Method
4783 ワード
java.lang
java.lang.Object java.lang.Class
Type Parameters:
All Implemented Interfaces:
Serializable , AnnotatedElement , GenericDeclaration , Type
Instances of the class
The following example uses a
It is also possible(可能)to get the
java.lang.Object java.lang.reflect.AccessibleObject java.lang.reflect.Method
All Implemented Interfaces:
AnnotatedElement ,
GenericDeclaration ,
Member
A
provides(提供)
information
about(関連),and
access(
アクセス)to,a single method on a class or interface.The
reflected(反射)method may be a class method or an instance method(including an abstract method).
A
Class Class<T>
Type Parameters:
T
- the type of the class modeled by this Class
object. For example, the type of String.class
is Class<String>
. Use Class<?>
if the class being modeled is unknown.All Implemented Interfaces:
Serializable , AnnotatedElement , GenericDeclaration , Type
public final class Class<T>
extends Object
implements Serializable, GenericDeclaration, Type, AnnotatedElement
Instances of the class
Class
represent(表示)classes and interfaces in a running Javaアプリケーション.An enum is akind(種類)of class and an annotation(注釈)is a kind of interface.Every array alsobelongs(属)to a class that isreflected(反射)as aClass
object that isshared(共有)by all arrays with the same element type and number ofdimensions(サイズ).Theprimitive(基本)Java types(boolean
,byte
,char
,short
,int
,long
,float
,anddouble
),and the keyword(キーワード)void
are also represented asClass
objects.Class
has no public cons tructor(構造方法).InsteadClass
objects are constructedautomatically(自動)by the JavaVirtual Machine(仮想マシン)as classes are loaded and by calls to thedefineClass
method in the class loader.The following example uses a
Class
object to print the class name of an object: void printClassName(Object obj) {
System.out.println("The class of " + obj +
" is " + obj.getClass().getName());
}
It is also possible(可能)to get the
Class
object for anamed(指定)type(or for void)using a class literal(字面).See Section 15.8.2 ofThe Java™ LanguageSpecification.For example: System.out.println("The name of class Foo is: "+Foo.class.getName());
java.lang.reflectClass Method
All Implemented Interfaces:
AnnotatedElement ,
GenericDeclaration ,
Member
public final class Method
extends AccessibleObject
implements GenericDeclaration, Member
A
Method
provides(提供)
information
about(関連),and
access(
アクセス)to,a single method on a class or interface.The
reflected(反射)method may be a class method or an instance method(including an abstract method).
A
Method
permits(許可)widening(拡張)conversions tooccur(発生)whenmatching(マッチング)the actual(実際の)parameters to invoke with theunderlying(ベース)method'sformal(形式の)parameters,but it throws anIllegalArgumentException
if anarrowing(収縮)conversion would occur.