<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Java - 從`HashMap`中刪除映射 > 原文: [https://beginnersbook.com/2014/07/java-remove-mapping-from-hashmap-example/](https://beginnersbook.com/2014/07/java-remove-mapping-from-hashmap-example/) #### 示例 在這個例子中,我們將看到如何使用鍵值對的鍵值從[`HashMap`](https://beginnersbook.com/2013/12/hashmap-in-java-with-example/)中刪除特定的映射。我們將使用以下`HashMap`類方法來執行此操作: `public Value remove(Object key)`:從此映射中移除指定鍵的映射(如果存在),并返回該特定鍵的元素值。更多關于[`remove`方法 Javadoc](https://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html#remove(java.lang.Object))。 **完整代碼:** ```java import java.util.HashMap; public class RemoveMappingExample { public static void main(String[] args) { // Creating a HashMap of int keys and String values HashMap<Integer, String> hashmap = new HashMap<Integer, String>(); // Adding Key and Value pairs to HashMap hashmap.put(11,"Value1"); hashmap.put(22,"Value2"); hashmap.put(33,"Value3"); hashmap.put(44,"Value4"); hashmap.put(55,"Value5"); hashmap.put(66,"Value6"); // Displaying HashMap Elements System.out.println("HashMap Elements: " + hashmap); // Removing Key-Value pairs for key 33 Object removedElement1 = hashmap.remove(33); System.out.println("Element removed is: " +removedElement1); // Removing Key-Value pairs for key 55 Object removedElement2 = hashmap.remove(55); System.out.println("Element removed is: " +removedElement2); // Displaying HashMap Elements after remove System.out.println("After Remove:"); System.out.println("--------------"); System.out.println("HashMap Elements: " + hashmap); } } ``` **輸出:** ```java HashMap Elements: {33=Value3, 55=Value5, 66=Value6, 22=Value2, 11=Value1, 44=Value4} Element removed is: Value3 Element removed is: Value5 After Remove: -------------- HashMap Elements: {66=Value6, 22=Value2, 11=Value1, 44=Value4} ```
                  <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>

                              哎呀哎呀视频在线观看