Reputation: 77
So i am watching tutorials this is the code
abstract class AnonymousInner {
public abstract void mymethod();
}
public class OuterClass {
public static void main(String args[]) {
AnonymousInner inner = new AnonymousInner() {
public void mymethod( ) {
System.out.println("this is an example of anonymous inner class");
}
};
inner.mymethod();
}
}
but after i type in this is not working cause the OuterClass "the public type must be defined in its own file"
Don't know why and asking for help.
Upvotes: 1
Views: 4404