[英]Unable to identify a particular reference in a Java program
public CompactSuffixTree(SimpleSuffixTree simpleSuffixTree)
{
super(simpleSuffixTree.text);
super.root = compactNodes(simpleSuffixTree.root, 0);
}
上面的代碼是后綴樹的Java實現的一部分。
在這里, CompactSuffixTree
擴展了AbstractSuffixTree
類,該類具有屬性“文本”。
simpleSuffixTree
類還擴展了AbstractSuffixTree
類。
“根”是Node
類類型的AbstractSuffixTree
類中的一個屬性。
誰能解釋一下代碼“ super(simpleSuffixTree.text);”的含義。 在這種情況下意味着什么?
注意: simpleSuffixTree
類中不存在屬性“ text”,這是我的主要困惑點simpleSuffixTree
super(simpleSuffixTree.text);
是對超類AbstractSuffixTree
的構造函數的調用。 simpleSuffixTree.text
被傳遞給超類的構造函數,它可能用於初始化AbstractSuffixTree
的“ text”屬性。
這意味着父構造函數被調用。 在這種情況下,它將導致對AbstractSuffixTree( String text )
函數的調用。
子類構造函數 -調用超類的構造函數的super
關鍵字,這是CompactSuffixTree
(子類)構造函數,該構造函數調用超類AbstractSuffixTree
構造函數,然后在AbstractSuffixTree
類中初始化根屬性。
此關鍵字 -您可以使用此關鍵字從實例方法或構造函數中引用當前對象的任何成員。 或者您可以使用此關鍵字引用超類公共或受保護成員,我建議您使用此關鍵字而不是super.root
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.