我有{% if addresses|length != 0 %}
{% set counter= 0 %}
{% for address in addresses %}
<input value="{{ address }}">
<p>{{balances[counter]|number_format(10, '.', ',')}} BTC / 0.00 USD</p>
{% set counter= counter+1 %}
{% endfor %}
{% else %}
<p>No addresses found!</p>
{% endif %}
。 HashMap<String, Object>
包含以下信息:Object
,name
和surname
。如何仅获取包含示例的对象:特定unique ID
?
答案 0 :(得分:0)
使用姓氏作为键
将对象存储在HashMap中HashMap<String, List<MyObject>> map = new HashMap<>();
map.putIfAbsent(myobj.surname, new List<MyObject>();
map.put(myobj.surname, map.get(myobj.surname).add(myobj));
map.get("surname");
答案 1 :(得分:0)
尝试过滤您的列表:
HashMap<String, YourObject> input =...;
如果你想要一个对象列表:
List<YourObject> result = input.values().stream()
.filter(o -> o.getSurname().equals("your filter surname"))
.collect(Collectors.toList());
如果你想要一个对象的hashmap
Map<String, YourObject> result = input.entrySet().stream()
.filter(e -> e.getValue().getSurname().equals("your filter surname"))
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));