0
親クラスの子クラス変数にアクセスしようとしています。どのように進めるかを教えてください。 以下のコードスニペットに基づいていますか?親クラスの子クラス変数を読み取る
public abstract class Base{
//some abstract methods
//one more method to parse the xml
public final void parseXml(){
String clName = Thread.currentThread().getStackTrace()[1].getClassName(); //child class name
if(xmlFile_+clName){ //i am trying to access "Test.xmlFile_Test",
//execute the if string is available
}
}
}
public class Test extends Base{
public static final String xmlFile_Test = "<Hello>sample</Hello>";
public int execute(){
parseXml(); //This should call base class method
}
}
私の間違ったステップがある。これはあなたが
より多くの情報を提供するために、何を達成しようとしていますか?ベースクラスから 'Test.xmlFile_Test'変数にアクセスしようとしていますか?または、派生されたメソッドから基本メソッドを呼び出すか? – Jack
はいジャック。私は親クラスの "Test.xmlFile_Test"にアクセスしようとしています。 –