Simple design and simple code, but not compiled:
public interface Insertable { public String getInsertStmt(String table); } public class ClassCanBeInserted implements Insertable { public String getInsertStmt(String table) {} } public class SomeClass { public static void main() { List<ClassCanBeInserted> list = new ArrayList<ClassCanBeInserted>(); SomeMethod(list); } private static void SomeMethod(List<Insertable> list) {} }
And the call to SomeMethod () will not compile. English is bad, but the code should explain. Can someone please find out what is wrong and how to get the design for the suggestion that a list of interface classes could be used in this method?
Again, the English are poor, so they may not express themselves well. Let me know your questions. Thanks!
Error message: SomeMethod (List) method of type ClassCanBeInserted is not applicable for arguments (List)
XM
source share