For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
public class B implements C{ public void doSomething() { System.out.println("i am B"); } } public interface C { public void doSomething(); } public class A implements C{ static ArrayList<C> al = new ArrayList(); /** * @param args */ public static void main(String[] args) { Random r = new Random(); if(r.nextInt()%2 == 0){ al.add(new B()); }else{ al.add(new A()); } C o = al.get(al.size()-1); o.doSomething(); } public void doSomething() { System.out.println("hello A"); } }