It is clear that this HashMap<Integer, HashMap<Integer, Rescue>>is not true, because then the value can be replaced time_id_policeby HashMap<Integer, Ambulance>. A similar thing can be done if you replaced Rescuewith ? extends Rescue.
However, using ? extendstwice gives us something that does not violate the type system.
HashMap<Integer, ? extends HashMap<Integer, ? extends Rescue>> getRescue() {
Java Map, .
Map<Integer, ? extends Map<Integer, ? extends Rescue>> getRescue() {
, :
return a ? time_id_police : time_id_ambulance;
, :
R.java:18: incompatible types
found : java.util.HashMap<java.lang.Integer,capture of ? extends java.util.HashMap<java.lang.Integer,? extends Rescue>>
required: java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,Rescue>>
return a ? time_id_police : time_id_ambulance;
^
1 error