我想知道是否有,如果我知道一個ArryList的一部分,我可以找出另一個。我遇到的問題是我對java的有限知識。從ArrayList中選擇特定的數據
我有列表設置爲:
spotsList = new ArrayList<HashMap<String, String>>();
活動經歷,並與PID和名稱添加的每一個現場(從服務器)到列表中的for循環:
HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_PID, id);
map.put(TAG_NAME, name);
spotsList.add(map);
如果我知道PID,現在有什麼方法可以獲得名稱?
謝謝你在前進,
泰勒
謝謝,但是它強調了map和hashmap指出了不正確的參數個數。另外,我將如何去添加equals()和hashcode()的覆蓋? – TylerM
確保先導入它們。對於equals()和hashCode(),請查看Apache Commons的構建器:http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/EqualsBuilder。 html和http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/HashCodeBuilder.html –
先導入什麼? Equals構建器和hashcode構建器? – TylerM