0

I have an interface:

public interface Table {
Long getId();
}

And a Class implementing it:

public class EquipmentTable implements Table {

    private Long id;
    public Long getId() {
        return id;
    }
}

Usage:

private List<Table> data = new ArrayList<EquipmentTable>();

Getting the following error:

Type mismatch: cannot convert from ArrayList<EquipmentTable> to List<Table>
3
  • how about another class AnotherTable implements Table? then your list will break the paradigm. You only want EquipmentTable then make List<EquipmentTable> Commented May 23, 2014 at 18:46
  • Btw, Java 7 Alleviates this by using diamond inference new ArrayList<>(); Commented May 23, 2014 at 18:48
  • well how one class can implements another clss?? Commented May 23, 2014 at 18:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.