【发布时间】:2019-08-31 11:51:04
【问题描述】:
我有一个 CountryModel 类,其中包含两列名称和代码,我的问题是我不知道如何在此进行预测搜索。
假设我想搜索国家名称是“Aruba”的位置,因为我有像 getName()这样的方法
ArrayList<CountryModel> countries = new ArrayList<>();
countries.add(new CountryModel("Afghanistan", "93"));
countries.add(new CountryModel("Australia", "61"));
countries.add(new CountryModel("Aruba", "297"));
我当然知道如何使用 contains() 函数搜索单个列,但这对我来说已成为一项艰巨的任务。
【问题讨论】:
-
搜索什么?一个完整的
CountryModel对象、一个名称、一个值,还是别的什么? -
我想在其中一个对象中搜索一个国家的名称
-
即使你把我的问题搁置,我已经得到了答案,我很高兴可以去。感谢那些提供答案的人