概念可以參考 Java Reflection 僅在實作上的語法稍加不同 scala> val s = classOf[String] s: java.lang.Class[String] = class java.lang.String scala> s. asInstanceOf asSubclass cast desiredAssertionStatus getAnnotation getAnnotations getCanonicalName getClassLoader getClasses getComponentType getConstructor getConstructors getDeclaredAnnotations getDeclaredClasses getDeclaredConstructor getDeclaredConstructors getDeclaredField getDeclaredFields getDeclaredMethod getDeclaredMethods getDeclaringClass getEnclosingClass getEnclosingConstructor getEnclosingMethod getEnumConstants getField getFields getGenericInterfaces getGenericSuperclass getInterfaces getMethod getMethods getModifiers getName getPackage getProtectionDomain getResource getResourceAsStream getSigners getSimpleName getSuperclass getTypeParameters isAnnotation isAnnotationPresent isAnonymousClass isArray isAssignableFrom isEnum isInstance isInstanceOf isInterface isLocalClass isMemberClass isPrimitive isSynthetic newInstance toString scala> val wf3 = classOf[WisdomFish02] wf3: java.lang.Class[WisdomFish02] = class WisdomFish02 scala> wf3. asInstanceOf asSubclass cast desiredAssertionStatus getAnnotation getAnnotations getCanonicalName getClassLoader getClasses getComponentType getConstructor getConstructors getDeclaredAnnotations getDeclaredClasses getDeclaredConstructor getDeclaredConstructors getDeclaredField getDeclaredFields getDeclaredMethod getDeclaredMethods getDeclaringClass getEnclosingClass getEnclosingConstructor getEnclosingMethod getEnumConstants getField getFields getGenericInterfaces getGenericSuperclass getInterfaces getMethod getMethods getModifiers getName getPackage getProtectionDomain getResource getResourceAsStream getSigners getSimpleName getSuperclass getTypeParameters isAnnotation isAnnotationPresent isAnonymousClass isArray isAssignableFrom isEnum isInstance isInstanceOf isInterface isLocalClass isMemberClass isPrimitive isSynthetic newInstance toString |
C06.物件導向設計(OOP) >