wood burning stoves 2.0
The moose likes Beginning Java and the fly likes setting value of map from another class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "setting value of map from another class" Watch "setting value of map from another class" New topic

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();


* @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.
I agree. Here's the link: http://aspose.com/file-tools
subject: setting value of map from another class
It's not a secret anymore!