wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Value update in hashmap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Value update in hashmap" Watch "Value update in hashmap" New topic
Author

Value update in hashmap

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202

I have a requirement to hold employee information in hashmap with fields like empid, name, salary and fields like FL1, FL2 etc. So I am getting all these informations from database and putting into a hashmap as below



Then I put this map into the list and return back to the calling function. If there are 1200 emp i will have list size as 1200..i.e. 1200 map obj. In course of this process, there are chances that FL1..FL10 etc have some negative values which should be converted back to zero. I could handle that in the while loop when putting into map, but due to some other business logic, i should not convert into ZERO until the while loop finishes.

Now, as the list contains 1200..map objects and since i have to convert negative values in some fields of the maps to zero..i require to loop again..this will create an introduction of another big loop. Please let me know if you have any other thoughts to meet this scenario.

Thanks in advance.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11311
    
  16

I'm not sure what you're asking for here. You basically say "I need to create all these objects, and only after I'm done can I check/change the values in each".

If that is your requirement, then what are you hoping to get from us?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

If storage isn't much of an issue you can store both values, with two keys per value. For example, key FLX (X = 1..10) maps to the modified value and FLX_ORIG (X = 1..10) maps to the original value.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Value update in hashmap