0

I have a hashmap where the key is UpgradePartType and the Value is an List of UpgradeParts. Why can't I put a List of EnginePart in the hashmap when EnginePart implements UpgradePart?

it works if I have a hashmap with values of IUpgradePart when i put en EnginePart

      private HashMap<UpgradePartType, ArrayList<IUpgradePart>> purchasedUpgrades;
       ...
      purchasedUpgrades  = new HashMap<UpgradePartType,ArrayList<IUpgradePart>>();
      purchasedUpgrades.put(UpgradePartType.Engine,new ArrayList<EnginePart>());

      ...        
      public enum EnginePart implements IUpgradePart{
      Stock,PortPolish,Bore,Tune
      }

      ...

also is it normal to have a blank interface?, I feel like there should be something in here

      public interface IUpgradePart{

      }
Thomas
  • 435
  • 6
  • 20

0 Answers0