Please consider the following snippet:
public interface MyInterface {
public int getId();
}
public class MyPojo implements MyInterface {
private int i
Try to use interfaces everywhere except when constructing instances, and you problems will go away:
public List getMyInterfaces()
{
List myInterfaces = new ArrayList(0);
myInterfaces.add(new MyPojo(0));
myInterfaces.add(new MyPojo(1));
return myInterfaces;
}
As others have said already, the use of MyInterface fixes your problem. It is also better to use the List interface instead of ArrayList for return types and variables.