jAVA 得到Map价值
生活随笔
收集整理的這篇文章主要介紹了
jAVA 得到Map价值
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
jAVA 獲取Map中的值
?
Map<String, String> map=new HashMap<String, String>(); map.put("name", "饒偉"); map.put("sex", "男"); map.put("address", "大連");方法1?
? ?
for (Map.Entry<String, String> MapString : map.entrySet()) { String key=MapString.getKey();//次方法獲取鍵值對的名稱 String value=MapString.getValue();//次方法獲取鍵值對的值 System.out.println(key+":"+value); }
方法2 ???
方法3
Map map = new HashMap(); map.put("dog", "狗"); map.put("cat", "貓"); map.put("monkey", "猴"); for(Object se:map.keySet()){ String s = (String)map.get(se); System.out.println(s); }
版權聲明:本文博主原創文章,博客,未經同意不得轉載。
轉載于:https://www.cnblogs.com/mengfanrong/p/4823708.html
總結
以上是生活随笔為你收集整理的jAVA 得到Map价值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html你可能还不知道的一些知识点
- 下一篇: OC字符串截取方法