小编tec*_*low的帖子

Java数据结构建议

我是这个领域的新手,所以请原谅我的愚蠢错误:) 所以我面临的问题是:在我的网页上,我正在显示一个表格。现在我的问题与表格的三列有关。

    First is : Area Code
    Second is : Zone Code
    Third is: Value
Run Code Online (Sandbox Code Playgroud)

这三者的关系是:

1 个区号有 6 个不同的区号,所有这 6 个区号都有相应的“值”

我对所有区号都有相同的区号:

   Zone codes are: 111, 222, 333, 444, 555, 666
Run Code Online (Sandbox Code Playgroud)

在浏览你的 stackoverflow 之后,我想我可以使用这个结构:

    Map<Integer, Map<Integer, Double>> retailPrices = new HashMap<Integer, Map<Integer, Double>>();
    Map<Integer, Double> codes = new HashMap<Integer, Double>(); 
Run Code Online (Sandbox Code Playgroud)

其中,reatailPrices 将区域代码和区域代码地图作为键,“值”作为值。

但是当我尝试通过 SQL 结果集填充它时,我收到以下错误:

put(Integer, Map<Integer,Double>)类型中 的方法Map<Integer,Map<Integer,Double>>不适用于参数 (Integer, Double)

在线的:

 while(oResult.next())

      retailPrices.put((new Integer(oResult.getString("AREA"))), (codes.put(new Integer(oResult.getString("ZONE_CODE")), new Double(oResult.getString("VALUE")))));


        }
Run Code Online (Sandbox Code Playgroud)

请帮我解决这个问题。我是否遵循正确的方法?

java data-structures jakarta-ee

3
推荐指数
1
解决办法
191
查看次数

标签 统计

data-structures ×1

jakarta-ee ×1

java ×1