Java data structure suggestion.

Posted by techoverflow on Stack Overflow See other posts from Stack Overflow or by techoverflow
Published on 2010-03-15T23:43:14Z Indexed on 2010/03/15 23:49 UTC
Read the original article Hit count: 239

Filed under:
|
|

Hi folks,

    I am a newbie in this field so please excuse my silly mistakes :)

    So the issue I am facing is:

    On my webpage, I am displaying a table. For now my issue is concerned with         three columns of the table.

    First is : Area Code
    Second is : Zone Code
    Third is: Value

    The relationship between these three is:

   1 Area Code has 6 different Zone code's and all those 6 Zone codes have corresponding "Value"

   I need a data structer that would give me the flexibility to get a "Value" for a Zone code, which falls under a particular Area code.

   I have the same zone codes for all the Area codes:

   Zone codes are: 111, 222, 333, 444, 555, 666

   After surfing your stackoverflow, I thought I can go with this structure:


    Map<Integer, Map<Integer, Double>> retailPrices = new HashMap<Integer, Map<Integer, Double>>();
    Map<Integer, Double> codes = new HashMap<Integer, Double>(); 

    where reatailPrices would hold an Area Code and a Map of Zone code as Key and "Value" as Value.

    but when I am trying to populate this through a SQL resultset, I am getting the following error:

    The method put(Integer, Map<Integer,Double>) in the type 

Map> is not applicable for the arguments (Integer, Double)

    on line:




  `while(oResult.next())

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


        }` 


   please help me figure out this problem. Am I following the right approach?

© Stack Overflow or respective owner

Related posts about java

Related posts about j2ee