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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Java 中的`LinkedHashSet`類 > 原文: [https://beginnersbook.com/2013/12/linkedhashset-class-in-java-with-example/](https://beginnersbook.com/2013/12/linkedhashset-class-in-java-with-example/) 之前我們已經在[`HashSet`](https://beginnersbook.com/2013/12/hashset-class-in-java-with-example/)和[`TreeSet`](https://beginnersbook.com/2013/12/treeset-class-in-java-with-example/)上分享了教程。[`LinkedHashSet`](https://docs.oracle.com/javase/6/docs/api/java/util/LinkedHashSet.html)也是`Set`接口的一個實現,它類似于`HashSet`和`TreeSet`,除了下面提到的差異: 1. `HashSet`不保持其元素的任何順序。 2. `TreeSet`按升序對元素進行排序。 3. `LinkedHashSet`保持插入順序。元素按照添加到`Set`中的相同順序進行排序。 ## `LinkedHashSet`的示例: ```java import java.util.LinkedHashSet; public class LinkedHashSetExample { public static void main(String args[]) { // LinkedHashSet of String Type LinkedHashSet<String> lhset = new LinkedHashSet<String>(); // Adding elements to the LinkedHashSet lhset.add("Z"); lhset.add("PQ"); lhset.add("N"); lhset.add("O"); lhset.add("KK"); lhset.add("FGH"); System.out.println(lhset); // LinkedHashSet of Integer Type LinkedHashSet<Integer> lhset2 = new LinkedHashSet<Integer>(); // Adding elements lhset2.add(99); lhset2.add(7); lhset2.add(0); lhset2.add(67); lhset2.add(89); lhset2.add(66); System.out.println(lhset2); } } ``` **輸出:** ```java [Z, PQ, N, O, KK, FGH] [99, 7, 0, 67, 89, 66] ``` 觀察輸出:兩種類型的`LinkedHashSet`都保留了插入順序。
                  <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>

                              哎呀哎呀视频在线观看