| Author |
setting value of map from another class
|
kamesh aru
Ranch Hand
Joined: Mar 16, 2002
Posts: 150
|
|
i have a class containg map with values set. i want to change this values from another class. here is the class with map public class Status { private static Map map = new HashMap(); Status(){ map.put("abc","true"); map.put("cfv","true"); map.put("vgf","true"); map.put("vfg","true"); } /** * @return */ public static Map getMap() { return map; } /** * @param map */ public static void setMap(Map map) { Status.map = map; } } i need to set the value of this map in other class can any one help me out thanks in advance
|
 |
Rick O'Shay
Ranch Hand
Joined: Sep 19, 2004
Posts: 531
|
|
What do you mean change the value of this map from another class? You have a getMap method so you can use that. Since it is static you setMap should synchronize: public void setMap(Map map) { Status.map = Collections.synchronizedMap(map); } You must make sure you only use the reference returned by getMap to manipulate the map.
|
 |
 |
|
|
subject: setting value of map from another class
|
|
|