implement two interfaces in an anonymous class
<p>I have two interfaces:</p>

<pre><code>interface A {
    void foo();
}

interface B {
    void bar();
}
</code></pre>

<p>I am able to create anonymous instances of classes implementing either of these interfaces like so:</p>

<pre><code>new A(){
    void foo(){}
}
</code></pre>

<p>or:</p>

<pre><code>new B(){
    void bar(){}
}
</code></pre>

<p>I want to create an anonymous class that implements both interfaces. Something like (the fictitious):</p>

<pre><code>new A implements B {
    void foo(){}
    void bar(){}
}
</code></pre>

<p>This obviously gives a compiler error: "B cannot be resolved to a type".</p>

<p>The workaround is quite simple:</p>

<pre><code>class Aggregate implements A, B {
    void foo(){}
    void bar(){}
}
</code></pre>

<p>I then use Aggregate where ever I would have used the anonymous class. </p>

<p>I was wondering if it is even legal for an anonymous class to implement two interfaces.</p>
