类<列表>或Class< List<>> [英] Class<List> or Class<List<?>>

查看:123
本文介绍了类<列表>或Class< List<>>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们有一个泛型类的类的变量,比如 List ,它应该是什么类型?

 类<列表> C1; 
//或
Class< List<?>> C2;


解决方案

第二个,因为第一个使用raw键入而不是泛型。

List 是原始的,但 List<?> 是通用的,您不应该在无论是原料还是仿制药。

If we have a variable for the class of a generic class, like List, what type should it be?

Class<List> c1;
//or
Class<List<?>> c2;

解决方案

The second one, because the first one uses the raw type instead of generics.

i.e. List is raw, but List<?> is generic, and you shouldn't mix-and-match between both raws and generics.

这篇关于类&LT;列表&gt;或Class&lt; List&lt;&gt;&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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