Java: How should I store thing per-user in memory -


I need to store specific values ​​for the username in memory, I'm thinking about something like the dynamic naming war Was, so that I do something like true

  ["bubby4j_falling"] =;   

and index it

  ["bubby4j_falling"]   

But, this is just an example, I know That would not work, I just want a way to speed and dynamically store things quickly and easily.

You want to use a map with a string key, for example hashmap & Lt; String, some & gt; .

Your example will look like this:

  Maps & lt; String, Boolean & gt; Map = new hashmap & lt; String, Boolean & gt; (); Map.put ("bubby4j_falling", true); If (map.get ("bubby4j_falling")) {...}   

Actually, in your case set < String & gt; more will be useful:

 set  & lt; String & gt; Falling users = new hashet & lt; String & gt; (); FallingUsers.add ("bubby4j"); If (fallingUsers.contains ("bubby4j")) {...}   

but uf already has the user objects (and you want), you Should do better set & lt; Users & gt; Use , or even use this fall to be the property of the user object only, after that you have to get the user objects by name in the Map & lt ; String, User & gt; may be.

Comments