【发布时间】:2012-12-04 01:18:25
【问题描述】:
可能重复:
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 与我的类是通用的有什么关系?
【问题讨论】:
-
你能把嵌套类设为静态吗?
-
我会说不要关闭为重复,只是因为这里有两块拼图,而那篇文章只解决了其中一个。
标签: java generics inheritance