gpt4 book ai didi

java - 使泛型类的内部类扩展 Throwable

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

<分区>

Possible Duplicate:
Why doesn’t Java allow generic subclasses of Throwable?

我正在尝试在这样的泛型类中创建一个常规的 RuntimeException:

public class SomeGenericClass<SomeType> {

public class SomeInternalException extends RuntimeException {
[...]
}

[...]
}

这段代码让我在 RuntimeException 这个词上出错说The generic class SomeGenericClass<SomeType>.SomeInternalException may not subclass java.lang.Throwable .

这个 RuntimeException 与我的类是泛型有什么关系?

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