java - 带参数的 Java 泛型 - 继承
问题描述
我有以下代码:
public class Inheritance {
class A<T,U,V>{
}
class B<T,U,V> extends A<T,U,T>{
}
}
有人可以解释一下,它实际上是如何工作的吗?B 类是否仅扩展 A 类,哪些参数是“T,U,T”,或者它扩展了实际的 A“T,U,V”类?
解决方案
A
's T
= B
' T
A
s U
= B
' U
A
s V
= B
'sT
B<String, Integer, Void> b = null;
A<String, Integer, String> a = b;
推荐阅读
- neo4j - Neo4j / Cypher - 查找路径,但该路径的中间节点不能是 X 类型
- lua - Lua 键盘/鼠标宏 - 释放键时停止
- python - 如何在 cur.execute 中使用 python 返回有效的时间戳值
- c++ - 当我们将指向结构类型参数的指针传递给函数时,C++ 编译错误
- html - 如何修复 SVG 投影剪切问题
- python - 读取 html 格式的 csv 文件“ParserError:错误标记数据。C 错误:第 103 行中应有 1 个字段,看到 2”
- r - 在 R 中绘制直方图
- go - 如果无法访问 gradle Go,则跳过 Bitbucket API
- php - 为什么 PHP intl v.1.1.0 为“-SV”返回“萨尔瓦多”?
- c# - 从“控制台应用程序”更改为“控制台应用程序(.Net Framework)”后找不到程序集引用,在当前上下文中不存在?