When I tried to do some sample on an abstract class
in Java I accidentally got some thing like anonymous inner class in Eclipse.
I have pasted the piece of code below. I don't understand how the abstract class
is related to anonymous class.
package com.Demo;
abstract class OuterClass {
abstract void OuterClassMethod();
}
public abstract class InnerClass extends OuterClass {
public static void main(String[] args) {
InnerClass myInnerClass = new InnerClass() {
@Override
void OuterClassMethod() {
int OuterClassVariable = 10;
System.out.println("OuterClassVariable" + " " + OuterClassVariable);
}
};
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…