Is there any other way

Without inserting the casting at each aPanel,

is there any other way to do this?

Inside the main, there is downcasting. Is there any other way

without casting...

package hiding.test;

publicclass ParentPanel{

public String aButton;

public ParentPanel(){

System.out.println("Hi, parent!");

}

publicvoid init(){

aButton =new String("aButtonAtParent");

System.out.println(aButton +"init() Parent");

}

}

package hiding.test;

publicclass ChildPanelextends ParentPanel{

public String aButton;

public ChildPanel(){

System.out.println("Hi, Child!");

}

publicvoid init(){

aButton =new String("aButtonAtChild");

System.out.println(aButton +"init() Child");

}

}

package hiding.test;

publicclass MainTest{

publicstaticvoid main(String[] args){

ParentPanel aPanel =new ChildPanel();

aPanel.init();

//-- Question ? : -

// without casting like this ( (ChildPanel) aPanel).aButton)

// is there any other way to do it?

System.out.println("===aPanel.aButton =" + ( (ChildPanel) aPanel).aButton);

}

[2669 byte] By [PaulSheldonII_Screena] at [2007-11-27 4:52:20]
# 1
Don't cross-post: http://forum.java.sun.com/thread.jspa?threadID=5174334You have been given help in your other thread.Kaj
kajbja at 2007-7-12 10:06:18 > top of Java-index,Java Essentials,Java Programming...