Why does the methods doesn't compile : <p>I have a multi catch exception block with a methods that doesn't compile , there's no inhertance relation between the two classes 
I still not able to define the rule behind this error ,this my code :</p>

<pre><code>class MyException extends RuntimeException {
    public void log() {
        System.out.println("Logging MyException");
    }
}

class MyException2 extends RuntimeException {
    public void log() {
        System.out.println("Logging MyException2");
    }
}

public class Test {
    public static void main(String[] args) {
        try {
            throw new MyException();
        } catch(MyException | MyException2 ex){
            ex.log(); // this doesn't compile !
        }
    }
}
</code></pre>
