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"에 액세스하려고합니다. –