![]() |
|
[Java] Call method from object in hashmap? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] Call method from object in hashmap? (/showthread.php?tid=5894715) |
Call method from object in hashmap? - Vanagander - Oct 12, 2018 It's late and I'm tired so it is fully possible I'm being retarded but anyways: I got a HashMap<Object, Object> in which I would like to call a setter method for all the object values in the map. Been trying to figure out a way to do it with replaceAll() but haven't had any success and my googling skills are a bit rusty (as in I've googled but came up empty handed), is this possible or am I being dumb? RE: Call method from object in hashmap? - Khamul - Oct 12, 2018 Code map.values().forEach(v -> v.setBlah(someValue));This should do what you need. If I've understood correctly... RE: Call method from object in hashmap? - Vanagander - Oct 12, 2018 (Oct 12, 2018 05:00 PM)Khamul Wrote: Precisely, thank you! |