PDA

View Full Version : How to use two keys in collections


madhoriya22
07-13-2007, 01:44 PM
Hi,
In my java program the result of my query is like this:-

PackageName Status Count
Order Selection Group Maintenance--->Fixed--------------->2
Part Maintenance-------------------->Fixed--------------->1
Factore Order Table Maintenance----->TBCI--------------->1
Factore Order Table Maintenance----->Removed----------->2
Factore Order Table Maintenance----->Works For Me------->1
Factore Order Table Maintenance----->On Work Plate------>1
Factore Order Table Maintenance----->Sent For Clarification>1
Factore Order Table Maintenance----->Fixed--------------->2
Product Line Maintenance------------>On Work Plate------->5
Product Line Maintenance------------>Fixed---------------->2
Product Line Maintenance------------>Removed------------->2
Product Line Maintenance------------>Works For Me--------->1


Now I want this packageName and status as a single key and count as value.
I am using HashMap. While retreiving these values back from HashTable...I have to recognise what Package is this and what is the count of different status.......I cant hardcode packageName(bcoz later they will increase) but I can hardcode status.......

Is there any way I can do this........

brad211987
07-13-2007, 03:01 PM
If I understand you correctly, you should be able to use packageName and status together by using a delimiter in your key. For example the key for the part maintenance line could be:

"Part Maintenance;Fixed"

Then you can use that key in your hash map to find the value. If you have the package name and status stored in variables it would be easy to create the key:

String key = packageName + ";" + status

madhoriya22
07-13-2007, 03:19 PM
Hi,

you are right brad......but while retreiving these keys from HashTable How I will recognise them separately.........i.e. This is packagaName and this is status.....