Java中“包含类的子类”的含义是什么?
我在阅读a paper时遇到了表达式“包含类的子类”。这在Java中是什么意思?这是报纸的摘录
Primarily, this entailed three things: (i) studying the implementation of the entity, as well as its usage, to reason about the intent behind the functionality; (ii) performing static dependency analysis on the entity, and any other types, methods, or fields referenced by it, including constants; and (iii) examining the inheritance hierarchy and subclasses of the containing class. This approach took considerable time and effort to apply.
# 1 楼答案
由于我没有这篇论文,这是我最好的猜测:在Java中,类可以以多种方式相互关联:除了相互继承之外,类还可以嵌套在彼此内部
下面是一个从嵌套类继承的类的示例:
在上面的示例中,
Inner
继承自Outer
,它充当其包含类# 2 楼答案
这个例子有一个包含类的子类:
ParentSubclass
是的子类,包含类Child
。请注意,在Parent
(或其子类)的之外,new Child()
将不起作用,因为需要一个包含(“外部”)类来实例化非static
“内部”类当你现在将一个方法
doSomething
添加到Parent
,在Child
中调用它,但在ParentSubclass
中重写它时,事情会变得有点疯狂这样的情况使得静态代码分析成为一个相当困难的问题