<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Java - 從`HashMap`獲取鍵集視圖 > 原文: [https://beginnersbook.com/2014/08/java-get-set-view-of-keys-from-hashmap/](https://beginnersbook.com/2014/08/java-get-set-view-of-keys-from-hashmap/) #### 描述 程序從`HashMap`獲取鍵集。 #### 示例 ```java import java.util.Iterator; import java.util.HashMap; import java.util.Set; class HashMapExample{ public static void main(String args[]) { // Create a HashMap HashMap<String, String> hmap = new HashMap<String, String>(); // Adding few elements hmap.put("Key1", "Jack"); hmap.put("Key2", "Rock"); hmap.put("Key3", "Rick"); hmap.put("Key4", "Smith"); hmap.put("Key5", "Will"); // Getting Set of HashMap keys /* public Set<K> keySet(): Returns a Set view of the keys contained * in this map. The set is backed by the map, so changes to the map * are reflected in the set, and vice-versa. */ Set<String> keys = hmap.keySet(); System.out.println("Set of Keys contains: "); /* If your HashMap has integer keys then specify the iterator like * this: Iterator<Integer> it = keys.iterator(); */ Iterator<String> it = keys.iterator(); // Displaying keys. Output will not be in any particular order while(it.hasNext()){ System.out.println(it.next()); } } } ``` **輸出:** ```java Set of Keys contains: Key2 Key1 Key4 Key3 Key5 ``` 注意:這組鍵由原始`HashMap`備份,因此如果從`Set`中刪除任何鍵,它將自動從`HashMap`中刪除。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看