Let's say I have a super class Car and my sub classes are Honda, Toyota, and Lexus.
I have 3 LinkedHashMaps using each sub class as the value:
LinkedHashMap<String, Honda> hondaModels = new LinkedHashMap<String, Honda>();
LinkedHashMap<String, Toyota> toyotaModels = new LinkedHashMap<String, Toyota>();
LinkedHashMap<String, Lexus> lexusModels = new LinkedHashMap<String, Lexus>();
What I am trying to achieve is something like this:
public <T> boolean checkModel(LinkedHashMap<String, <T>> lineup, String model) {
if (lineup.containsKey(model)) {
return true;
}
return false;
}
Is it possible for me to create a method by specifying LinkedHashMap with a generic value as a parameter so I don't have to repeat the same method for all 3 LinkedHashMaps?