1.Type定义与说明

源代码:

package java.lang.reflect;/*** 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.** @since 1.5*/
public interface Type {/*** Returns a string describing this type, including information* about any type parameters.** @implSpec The default implementation calls {@code toString}.** @return a string describing this type* @since 1.8*/default String getTypeName() {return toString();}
}

总结来说:

  • Type是一个接口。
  • Type是Java中所有类型的父接口
  • Type包括:raw type(原始类型,对应Class),parameterized types(参数化类型), array types(数组类型), type variables(类型变量) and primitive types(基本类型,对应Class).
  • Type是JDK1.5引入的,主要是为了泛型。

2.Class定义与说明

源代码:

/*** Instances of the class {@code Class} represent classes and* interfaces in a running Java application.  An enum is a kind of* class and an annotation is a kind of interface.  Every array also* belongs to a class that is reflected as a {@code Class} object* that is shared by all arrays with the same element type and number* of dimensions.  The primitive Java types ({@code boolean},* {@code byte}, {@code char}, {@code short},* {@code int}, {@code long}, {@code float}, and* {@code double}), and the keyword {@code void} are also* represented as {@code Class} objects.** <p> {@code Class} has no public constructor. Instead {@code Class}* objects are constructed automatically by the Java Virtual Machine as classes* are loaded and by calls to the {@code defineClass} method in the class* loader.** <p> The following example uses a {@code Class} object to print the* class name of an object:** <blockquote><pre>*     void printClassName(Object obj) {*         System.out.println("The class of " + obj +*                            " is " + obj.getClass().getName());*     }* </pre></blockquote>** <p> It is also possible to get the {@code Class} object for a named* type (or for void) using a class literal.  See Section 15.8.2 of* <cite>The Java&trade; Language Specification</cite>.* For example:** <blockquote>*     {@code System.out.println("The name of class Foo is: "+Foo.class.getName());}* </blockquote>** @param <T> the type of the class modeled by this {@code Class}* object.  For example, the type of {@code String.class} is {@code* Class<String>}.  Use {@code Class<?>} if the class being modeled is* unknown.** @author  unascribed* @see     java.lang.ClassLoader#defineClass(byte[], int, int)* @since   JDK1.0*/
public final class Class<T> implements java.io.Serializable,GenericDeclaration,Type,AnnotatedElement {}

总结来说:

  • Class是一个类。
  • Class对象代表着正在运行的Java程序中的类型和接口:enum、annotation、array以及基本类型(8种)都可以用Class对象表示。
  • Class没有public构造器。
  • 当类被加载或者在class loader中被方法调用时,JVM会自动构造Class对象。

3.Type接口与Class类的区别联系

  • TypeClass的父接口。
  • ClassType的子类。

Java中Type接口与Class类的区别联系相关推荐

  1. Java中List接口重要实现类一ArrayList

    1.java.util.ArrayList 集合数据存储的结构是数组结构.元素查找快,而增删就比较慢 所以如果要查询数据,遍历数据,ArrayList是最常用的集合 2.ArrayList是不同步的, ...

  2. java中model接口与实现类_关于java中dao,model,service,impl,util的理解

    dao 与数据库的操作,增删改查等方法 model 一般都是javabean对象,例如与数据库的某个表相关联. service 供外部调用,等于对dao,model等进行了包装. impl 定义的接口 ...

  3. Java中的Type接口和Class类区别和联系

    Java中的Type接口和Class类有什么区别 Type是Class的父接口. Type 是 Java 编程语言中所有类型的公共高级接口.它们包括原始类型.参数化类型.数组类型.类型变量和基本类型. ...

  4. java中get接口示例_Java即时类| 带示例的get()方法

    java中get接口示例 即时类的get()方法 (Instant Class get() method) get() method is available in java.time package ...

  5. java中get接口示例_Java LocalDateTime类| 带示例的get()方法

    java中get接口示例 LocalDateTime类的get()方法 (LocalDateTime Class get() method) get() method is available in ...

  6. Java 中 Comparable 接口的意义和用法.

    在之前的博文中已经介绍了Java中Collection 接口和 Collections类. http://blog.csdn.net/nvd11/article/details/21516075 一, ...

  7. java vector实现的接口_java中List接口的实现类 ArrayList,LinkedList,Vector 的区别 list实现类源码分析...

    java面试中经常被问到list常用的类以及内部实现机制,平时开发也经常用到list集合类,因此做一个源码级别的分析和比较之间的差异. 首先看一下List接口的的继承关系: list接口继承Colle ...

  8. Java中实现接口与继承的区别

    ** Java中实现接口与继承的区别 ** 首先,先来了解一下什么是接口和继承.接口一般是使用interface来定义的.接口定义同类的定义类似,分为接口的声明和接口体,其中接口体由常量定义和方法定义 ...

  9. Objective-C 入门(七)协议 protocol(JAVA中的接口)

    Objective-C 入门(七)协议 protocol(JAVA中的接口) 接口的作用想必大家都比较了解 OV中的 protocol 相比接口作用相似 语法稍有不同 1.先来看声明一个协议 在创建文 ...

最新文章

  1. MATLAB实战系列(二十七)-数据预处理-PCA主成分分析
  2. 骗人的数学题,那消失的1块钱到底被谁拿走了
  3. [蓝桥杯2017初赛]Excel地址
  4. 【转】 Pro Android学习笔记(九一):了解Handler(5):组件生命
  5. Python程序的执行过程
  6. MySQL远程连接ERROR 2003 (HY000) Cant connect to MySQL server on (10060)
  7. android app入口函数,Android App程序运行过程 ActivityThread.main()------详解系列(一)...
  8. 中信银行Java笔试题库,手撕面试官
  9. PHP高并发高负载下的3种实战场景解决方法
  10. 期货计算机撮合成交的原则,期货ABC之行情及基本术语:八、价格优先、时间优先及撮合成交价的确定...
  11. Could not set the project description for 'hotelseqbid.ws' because the project d
  12. Android开发之中文语音朗读
  13. JVM cpu过高排查
  14. 服务器老被攻击,该如何解决?
  15. uva122Treea on the leval(二叉树遍历)
  16. thegraph subgraph 踩坑之入门青铜
  17. 推出更安静的通知权限界面
  18. 1、 Seata快速开始
  19. 如何下载python编译器,以及python 编译器如何使用 图文详解
  20. 企业财务制度二--(五)损益类科目 5101 主营业务收入(转载)

热门文章

  1. 数据规整化:清理、转换、合并、重塑 《用Python进行数据分析》读书笔记第7章
  2. 内部样式表、外部样式表、内联样式表
  3. 什么是架构?什么是架构师?
  4. Javascript——高级进阶
  5. ORACLE存储过程RECORD数据类型的使用
  6. jop怎么读音英语怎么说_job是什么意思_ job的翻译_音标_读音_用法_例句_爱词霸在线词典...
  7. river歌曲表达的意思_英文歌曲_river是什么意思_沪江英语
  8. SRE重案调查组 第三集 | 探秘HTTP异步请求的“潘多拉魔盒”
  9. 【数据结构oj】树的度(树和二叉树的相互转化)
  10. 英语发音规则---I字母