T
Tom
Doesn't java support overriding inner classes?
// BEGIN EXAMPLE
// class code ------------------------------------------
public class ClassA{
LocalClass instance;
// inner class
private class LocalClass{
public void doit(){
System.out.println("Hello");
}
}
ClassA(){
instance = new LocalClass();
}
public void doit(){
instance.doit();
}
}
public class ClassB extends ClassA{
LocalClass instance;
// inner class
private class LocalClass{
public void doit(){
System.out.println("Goodbye");
}
}
}
public class Main
{
public static void main(String[] args){
ClassA ca;
ClassB cb;
ca = new ClassA();
cb = new ClassB();
ca.doit();
cb.doit();
}
}
// output -------------------------------------
$ java Main
Hello
Hello
// END EXAMPLE
Me is confused!
Tom
// BEGIN EXAMPLE
// class code ------------------------------------------
public class ClassA{
LocalClass instance;
// inner class
private class LocalClass{
public void doit(){
System.out.println("Hello");
}
}
ClassA(){
instance = new LocalClass();
}
public void doit(){
instance.doit();
}
}
public class ClassB extends ClassA{
LocalClass instance;
// inner class
private class LocalClass{
public void doit(){
System.out.println("Goodbye");
}
}
}
public class Main
{
public static void main(String[] args){
ClassA ca;
ClassB cb;
ca = new ClassA();
cb = new ClassB();
ca.doit();
cb.doit();
}
}
// output -------------------------------------
$ java Main
Hello
Hello
// END EXAMPLE
Me is confused!
Tom