Results 1 to 2 of 2

Thread: HashMap

  1. #1
    koolhoney is offline Member
    Join Date
    Sep 2008
    Rep Power

    Default HashMap

    Hi All,

    I am new to java.Please help me in using hashmap.

    I have records in Database like,

    DeptID, empName, tasks

    10 GR task1
    10 GR task2
    10 GBC task3
    20 ABC task4
    10 GBC task5
    20 GR task6
    10 ABC task7
    10 ABC task8
    10 GBC task9
    10 GR task10
    20 GBC task11
    20 GR task12
    20 GBC task13
    10 GR task14
    20 ABC task15

    now i am fetching the data and putting in my Java Bean.

    Now my requirement is i have to get the count for paticular deptID(For Example 10) and for partcular empName(For Example GR) how many tasks are there and appended task data.
    output is like:

    DeptId empName count appending the taks data
    10 GR 7 task1,task2,...
    10 ABC 5 task 4,task7...
    10 GBC 4
    20 GR 2
    20 GBC 5

    I am trying it to achieve using HashMap.

    HashMap s = new HashMap();
    MyBean m = new MtBean();
    s.put(m.getDeptId()+"-"+m.getEmpName() , here value is appending the taks data );

    Hash map allows duplicate keys. for 10-GR keys it will append the tasksdata. i am tryinh in this way.
    Please guide me.

    Thanks in adv..

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Rep Power


    If the information is in a database, the proper 'select' command will return what you want.

    select task from ...whatever... where empName = ...whatever and DeptID = ...whatever...


Similar Threads

  1. Hashmap to TXT and TXT to Hashmap
    By elvinny in forum Advanced Java
    Replies: 4
    Last Post: 02-17-2011, 12:12 AM
  2. Hashmap
    By dirtycash in forum New To Java
    Replies: 5
    Last Post: 12-03-2007, 03:58 AM
  3. what is hashmap
    By gabriel in forum New To Java
    Replies: 5
    Last Post: 08-03-2007, 02:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts