久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      java中如何判斷map集合中是否存在key

      java中如何判斷map集合中是否存在key

      有兩種方法可以判斷map集合中是否存在某個key。

      方法1:直接使用java api提供的containsKey()

      方法2:循環(huán)遍歷,逐個比較。

      java相關(guān)視頻推薦:java視頻

      具體實現(xiàn)代碼如下:

      import java.util.Iterator; import java.util.Map;   import com.google.common.collect.Maps;   public class MapTest {   	public static void main(String[] args) { 		 		Map<String, String> map = Maps.newHashMap(); 		map.put("1", "1"); 		map.put("2", "2"); 		map.put("3", "3"); 		map.put("4", "4"); 		 		//方法1 		System.out.println(map.containsKey("5")); 		 		//方法2 		Iterator keys = map.keySet().iterator(); 		String key; 		while(keys.hasNext()){ 			key = (String) keys.next(); 			if ("1".equals(key)) { 				System.out.println("存在"); 			}  		} 	}   }

      java相關(guān)文章教程推薦:java開發(fā)入門

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號