什么是参数化类型? [英] What is meant by parameterized type?

查看:86
本文介绍了什么是参数化类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

链接声明如下:


具有实际类型参数的泛型类型的实例化称为参数化类型。
示例(参数化类型):

集合< String> coll = new LinkedList< String>();


那么什么是参数化类型?


  • 集合< String>

  • LinkedList< String>


解决方案

它们都是参数化类型:将其他类型作为参数的类型。



表达式两边有不同类型的事实是不相关的,必须做多态行为,即因为 LinkedList 集合的子类型。


This link states the following:

The instantiation of a generic type with actual type arguments is called a parameterized type . Example (of a parameterized type):

Collection<String> coll = new LinkedList<String>();

So what is the parameterized type?

  • Collection<String> or
  • LinkedList<String>

解决方案

They are both parameterized types: types that take other types as parameters.

The fact that you have different types on the two sides of the expression is irrelevant, and has to do with polymorphic behavior i.e. because LinkedList is a subtype of Collection.

这篇关于什么是参数化类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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