Media000 Media000 - 9 months ago 60
Java Question

Insert value into HashMap using method

I'm new to Java, and I've set up a HashMap for which I ask the user for some data which is then added like this:

map.put(id, new User(id, name, phone, email));

If I want to change the value of one of the attributes in the constructor, say
for example, how would I do that?

I've researched similar answers but they all talk about cases where you have a key and a value, however in my case I have a key and a constructor. I guess my follow up question is, seeing that in my
class I also have a setter called
, is it possible to incorporate it into the solution?

Many thanks


How about try the following code: