一、java.lang.reflect.Type
Type is the common superinterface for all types in the Java programming language. These include raw types, parameterized types,array types, type variables and primitive types.
public interface Type {
/**
* Returns a string describing this type, including information
* about any type parameters.
*/
default String getTypeName() {
return toString();
}
}
说明:Class类也是Type接口的子类,所以:
public void bind(Type type) {
System.out.println(type.getTypeName());
}
bind(Test.class); //测试调用
上面的测试会输出Test类的完整的名称(即包含包名)
本文介绍了 Java 中 Type 接口的基本概念及其使用方法。Type 是 Java 编程语言中所有类型的公共超接口,包括原始类型、参数化类型、数组类型、类型变量和原始类型。此外,还详细解释了 Class 类作为 Type 的子类的应用实例。
565

被折叠的 条评论
为什么被折叠?



