作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Java 中有以下语句。
public classG<A extends X & Y & Z>
由于这个问题需要Java知识,所以我假设X
, Y
& Z
都是Java类。但据我所知,在Java中,一个类不能扩展多个类。那么关于 X
、Y
和 Z
类的正确假设是什么?它们都是 Java 接口(interface)吗?
最佳答案
绑定(bind)类型声明中的extends
子句可以引用泛型类型扩展的类或它实现的接口(interface)。如果一个类出现在列表中,它必须排在第一位。
因此,换句话说,X
可能是类或接口(interface),而 Y
和 Z
是接口(interface)。
关于java - public classG<A extends X & Y & Z> 关于 Java 中的泛型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68135036/
我是一名优秀的程序员,十分优秀!