在HashMap中搜索给定键的值将返回null

时间:2016-12-03 12:37:10

标签: java android hashmap

以下结果是我的HashMap值,我通过循环子句填充

private Map<String, String> days = new HashMap<>();

0 = {HashMap$HashMapEntry@4952} "2131689719" -> "2016-11-25"
1 = {HashMap$HashMapEntry@4953} "2131689683" -> "2016-11-26"
2 = {HashMap$HashMapEntry@4954} "2131689692" -> "2016-11-27"
3 = {HashMap$HashMapEntry@4955} "2131689686" -> "2016-11-26"
4 = {HashMap$HashMapEntry@4956} "2131689716" -> "2016-12-01"

现在,当我尝试搜索给定键的值时,例如:

days.get("2131689719")

我得到null

更新:

int day         = 0;
int dateOfWeeks = 10;
for (int i = 0; i <= 6; i++) {
    ((TextView) findViewById(food_list_values[i])).setText(dayOfWeeks[day]);
    days.put(String.valueOf((findViewById(food_list_values[i])).getId()), foodList.get(dateOfWeeks).getDate());
    day++;
    dateOfWeeks++;
}

0 个答案:

没有答案