Say I have an object called Car:
public class Car(){
String model;
String brand;
Integer yearReleased;
float price;
}
and create a treemap of cars called cars:
TreeMap<Integer, Car> cars = new TreeMap<Integer, Car>();
Is there a method wherein I can search up the model of a car in the treelist? Something like .getKey() but allows to search an object variable. I'm trying to create a search function wherein it has a parameter of the treemap and the model to be searched and returns the key.
public searchModel(TreeMap<Integer, Car> list, String model){
return list.getKey(model);
}