Why does this not work...
public ArrayList getEdges() {
return A;
//A is an Arraylist of type \'Action\'. Action implements Ed
This is because ArrayList is not covariant on the type E. That is, you cannot substitute an instance of ArrayList for ArrayList just because Derived inherits from Base.
Consider this case: String inherits from Object; however, if this meant you could use an ArrayList as an ArrayList then the following code would be possible:
ArrayList
The above can't work, because you can't add an Integer to an ArrayList. If you could, then this could happen:
ArrayList stringList = (ArrayList)list;
String string = stringList.get(0); // Not a string!
As Ziyao has indicated, the correct way to implement this is to use the ? extends Edge syntax.