Class Method

4783 ワード

java.lang

Class Class<T>

  • java.lang.Object
  • java.lang.Class

  • 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 classClassrepresent(表示)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 aClassobject 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(キーワード)voidare also represented asClassobjects.Classhas no public cons tructor(構造方法).InsteadClassobjects are constructedautomatically(自動)by the JavaVirtual Machine(仮想マシン)as classes are loaded and by calls to thedefineClassmethod 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 theClassobject 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.reflect

    Class Method

  • java.lang.Object
  • java.lang.reflect.AccessibleObject
  • java.lang.reflect.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).
    AMethodpermits(許可)widening(拡張)conversions tooccur(発生)whenmatching(マッチング)the actual(実際の)parameters to invoke with theunderlying(ベース)method'sformal(形式の)parameters,but it throws anIllegalArgumentExceptionif anarrowing(収縮)conversion would occur.