什么时候在Java中进行泛型定义和实例化的类型检查? [英] When does type checking of generic definitions and instantiations happen in Java?

查看:241
本文介绍了什么时候在Java中进行泛型定义和实例化的类型检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,


  • 是否会在编译时进行泛型定义的类型检查?


  • 是否在运行时对泛型实例进行类型检查?






我的问题出现在

在编译时,在编译使用泛型的定义或代码时进行检查。运行时代码中没有泛型。


In Java,

  • does type checking of generic definitions happen at compile time?

  • does type checking of instantiations of generics happen at run time?

Thanks.

My questions arise when having the same questions for C#

解决方案

Generics is only checked at compile time, when compiling the definition or code that uses generics. There is no generics in the code at runtime.

这篇关于什么时候在Java中进行泛型定义和实例化的类型检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆