public class CityList{
public static void main(String[] args){
ConcurrentHashMap<Integer,String> hm=new ConcurrentHashMap<Integer,String>();
hm.put(10,"AAAA");
hm.put(11."BBBB");
}
}
// another class
public class Getcity extends CityList{
public static void main(String[] args){
public void showcity(int i)
{
system.out.println(hm.get(i);
}
我创建了一个类并ConcurrentHashMap
在该类中实现。现在我想使用其他类中的另一种方法访问该 Map 的特定元素。请帮助我。如果我将i值传递为10
,它应该显示AAAA
。请告诉我如何做到这一点。