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 Android Security Essentials Live Lessons this week in the Android 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.
subject: setting value of map from another class
Similar Threads
Problem with HashMap
Is there somthing called optional parameters...
How can I Iterate a map
non-static reference in singleton
Handler Class - Is it correct?