An anonymous class can extend only from one class or interface, so I can't do the next :
interface Enjoyable {
    public void enjoy();
}
interface Exercisable {
    public void exercise();
}
public class Test {
    public static void main(String[] args) {
        new Enjoyable implements Exercisable() {
            public void enjoy() {
                System.out.println(":D");
            }
        }.enjoy();
    }
}
It says that :
Enjoyable.Exercisable cannot be resolved to a type
I'm trying to replicate this behavior and I wrote the next code:
interface Enjoyable {
    interface Exercisable {
        public void exercise();
    }
    public void enjoy();
}
public class Test {
    public static void main(String[] args) {
        new Enjoyable.Exercisable() {
            public void enjoy() {
                System.out.println(":D");
            }
            public void exercise() {
                System.out.println("Doing exercise !!!");
            }
        }.exercise();
        new Enjoyable.Exercisable() {
            public void enjoy() {
                System.out.println(":D");
            }
            public void exercise() {
                System.out.println("Doing exercise !!!");
            }
        }.enjoy();
    }
}
And then I get :
Doing exercise !!! :D
Are there another way to simulate It? And way i hace to implement both metods un the anonymous class ?
Thanks
 
     
     
    