[英]Unable to identify a particular reference in a Java program
public CompactSuffixTree(SimpleSuffixTree simpleSuffixTree)
{
super(simpleSuffixTree.text);
super.root = compactNodes(simpleSuffixTree.root, 0);
}
The above code is a part of a java implementation of the suffix tree. 上面的代码是后缀树的Java实现的一部分。
Here the CompactSuffixTree
extends AbstractSuffixTree
class which has an attribute "text". 在这里,
CompactSuffixTree
扩展了AbstractSuffixTree
类,该类具有属性“文本”。
The simpleSuffixTree
class also extends the AbstractSuffixTree
class. simpleSuffixTree
类还扩展了AbstractSuffixTree
类。
"root" is an attribute in the AbstractSuffixTree
class of type Node
class. “根”是
Node
类类型的AbstractSuffixTree
类中的一个属性。
Can anyone please explain what does the code "super(simpleSuffixTree.text);" 谁能解释一下代码“ super(simpleSuffixTree.text);”的含义。 mean in such a context?
在这种情况下意味着什么?
NOTE: the attribute "text" is not present in the simpleSuffixTree
class, which is my main point of confusion.strong text 注意:
simpleSuffixTree
类中不存在属性“ text”,这是我的主要困惑点simpleSuffixTree
super(simpleSuffixTree.text);
is a call to the constructor of the super-class AbstractSuffixTree
. 是对超类
AbstractSuffixTree
的构造函数的调用。 simpleSuffixTree.text
is passed to the super-class's constructor, and it's probably used to initialize the "text" property of AbstractSuffixTree
. simpleSuffixTree.text
被传递给超类的构造函数,它可能用于初始化AbstractSuffixTree
的“ text”属性。
It means that the parent constructor is being called. 这意味着父构造函数被调用。 In this case, it'll result in a call to the
AbstractSuffixTree( String text )
function. 在这种情况下,它将导致对
AbstractSuffixTree( String text )
函数的调用。
Subclass Constructors - super
keyword to invoke a superclass's constructor, Here is the CompactSuffixTree
(subclass) constructor that calls the superclass AbstractSuffixTree
constructor and then initialize root attribute in AbstractSuffixTree
class. 子类构造函数 -调用超类的构造函数的
super
关键字,这是CompactSuffixTree
(子类)构造函数,该构造函数调用超类AbstractSuffixTree
构造函数,然后在AbstractSuffixTree
类中初始化根属性。
this Keyword - You can refer to any member of the current object from within an instance method or a constructor by using this. 此关键字 -您可以使用此关键字从实例方法或构造函数中引用当前对象的任何成员。 or you can refer super class public or protected members using this keyword, I will recommend you use this keyword instead of
super.root
. 或者您可以使用此关键字引用超类公共或受保护成员,我建议您使用此关键字而不是
super.root
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.