作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些代码:
class MyClass<RCM>
private List<RCM> allPreExistingConfigsForCodes() {
if(this.allCodesForThisType.size() == 0)
return new ArrayList<RCM>(0);
IntelliJ 告诉我应该替换 new ArrayList<RCM>
与 new ArrayList<>
这意味着什么?
最佳答案
来自Java Tutorials generics lesson :
In Java SE 7 and later, you can replace the type arguments required to invoke the constructor of a generic class with an empty set of type arguments (
<>
) as long as the compiler can determine, or infer, the type arguments from the context. This pair of angle brackets,<>
, is informally called the diamond. For example, you can create an instance ofBox<Integer>
with the following statement:
Box<Integer> integerBox = new Box<>();
关于java - 对于java泛型来说<>意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57661716/
我是一名优秀的程序员,十分优秀!