• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Value update in hashmap

 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic