David.Lin
David.Lin

Reputation: 77

the public type must be defined in its own file

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

Answers (1)

AnOldSoul
AnOldSoul

Reputation: 4197

What's the name of the file? It should be OuterClass.java.

Upvotes: 2

Related Questions