1
我有一個問題,我想不通。 我有一個電話號碼列表,其表示爲:用戶有應用程序 我也有我的手機中所有聯繫人的樹形圖 我想比較所有擁有該應用程序的用戶到我的聯繫人樹形圖,以便如果用戶有應用程序 - 我可以將它們添加爲朋友,但如果他們不這樣,我可以發送文本邀請。這是我的,但它不工作:迭代器的循環邏輯
Iterator<Entry<String, String>> it = contacts.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> pairs = (Map.Entry<String, String>)it.next();
for(int i = 0; i < users.size(); i++) {
String userNumber = Helper.formatNumber(users.get(i).getString("phone"));
if(pairs.getValue().equals(userNumber)) { //they have the app
contact_data.add(new Contact(pairs.getKey().toString(), pairs.getValue().toString(), true));
} else { //they don't have the app
contact_data.add(new Contact(pairs.getKey().toString(), pairs.getValue().toString(), false));
}
}
it.remove(); // avoids a ConcurrentModificationException
}
詳細說明「它不工作」。你收到什麼錯誤信息?目前的結果是什麼? – Tristan