Using an interface as a constructor parameter in Java?

Posted by aperson on Stack Overflow See other posts from Stack Overflow or by aperson
Published on 2010-04-06T20:13:44Z Indexed on 2010/04/06 20:23 UTC
Read the original article Hit count: 197

How would I be able to accomplish the following:

public class testClass implements Interface {
     public testClass(Interface[] args) {
     }
}

So that I could declare

Interface testObject = new testClass(new class1(4), new class2(5));

Where class1 and class2 are also classes that implement Interface.

Also, once I accomplish this, how would I be able to refer to each individual parameter taken in to be used in testClass?

Thanks :)

© Stack Overflow or respective owner

Related posts about java

Related posts about constructor