gpt4 book ai didi

java - Eclipse for Java 中的 "unavoidable generic type problems"是什么?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:03:25 24 4
gpt4 key购买 nike

在“错误/警告”面板中设置 Java 编译器的首选项时,Eclipse 可以配置为“忽略不可避免的泛型类型问题”。

Java 中这种“不可避免”的泛型类型问题是什么?忽略这些安全吗?它们什么时候出现?

最佳答案

来自 the documentation特征:

When enabled, the compiler will issue an error or a warning even when it detects a generic type problem that could not have been avoided by the programmer. As an example, a type may be forced to use raw types in its method signatures and return types because the methods it overrides from a super type are declared to use raw types in the first place.

所以,例如:

class Test {
public void method(ArrayList list) {
}
}

class TestSub extends Test {

@Override
public void method(ArrayList list) {
// ^^^^^^^^^
// Complain on use of raw type or not?

System.out.println("Overridden");
}
}

关于java - Eclipse for Java 中的 "unavoidable generic type problems"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9762717/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com