import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
 
 
public class Demo {
    public static void main(String[] args) {
        HashMap<Object,Object> map = new HashMap<Object,Object>();
        map.put(1,"三国");//值是字符串
        map.put("数组",new int[]{1,2,3});//值是数组
        map.put(null, null);//值是null
        map.put(map,map);//值是map自己
        map.put('A',2.8 );//值是浮点数
         
        Iterator<Entry<Object,Object>> it = map.entrySet().iterator();
        while(it.hasNext()){
            Entry<Object,Object> e = it.next();
            System.out.println(e.getKey()+","+e.getValue());
        }
    }
}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2021-06-24
  • 2021-04-26
相关资源
相似解决方案