How do I implement a static map class to be used by a few other classes?
examples to follow will be great.
Java
Last Comment
gudii9
8/22/2022 - Mon
for_yan
can you please elaborate?
HashMap as any Java object can be made static and then you could address it by refereinng to the class name rather than the instance of the class where it is a field
So if you declare it like that:
class ClassName {
public static HashMap<Integer, String> map;
...
}
Thane in any other class of your applucation you can address it like that:
HashMap as any Java object can be made static and then you could address it by refereinng to the class name rather than the instance of the class where it is a field
So if you declare it like that:
class ClassName {
public static HashMap<Integer, String> map;
...
}
Thane in any other class of your applucation you can address it like that:
ClassName.map.get(key)
thsi is no different form any other static object