0
//Mysql Query to get project

while(query.next())
{
    Map objname=new Hashmap();
    //Mysql query to get day and hours of respective project
    while(dayandhourquery.next())
    {
        objname.put(day,hour);
    }
}

我有一个查询来获取项目名称、日期和小时数。我想将日期和小时数放入相应项目的 Hashmap 中。在执行上述代码时,我正在获取最后一个项目的详细信息。

4

1 回答 1

1

It happen because Map stores only values for unique keys. I assume that for project days could be the same. When you put day value you override old day-hour entry in map. You need to consider changing key value in map or use one collection for each project.

于 2013-11-06T09:54:36.870 回答