<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 - 替換`LinkedList`中的元素 > 原文: [https://beginnersbook.com/2014/07/java-replace-element-in-a-linkedlist-example/](https://beginnersbook.com/2014/07/java-replace-element-in-a-linkedlist-example/) 在上一篇文章中,我們分享了[在`LinkedList`中搜索元素](https://beginnersbook.com/2014/07/java-search-elements-in-linkedlist-example/)的教程。在這里,我們將看到如何使用元素的索引用[`LinkedList`](https://docs.oracle.com/javase/7/docs/api/java/util/LinkedList.html) 中的新值替換現有元素值。 #### 示例 我們在下面的程序中使用的方法是: `public E set(int index, E element)`:用指定的元素替換此列表中指定位置的元素。 **完整代碼:** ```java import java.util.LinkedList; public class ReplaceInLinkedList { public static void main(String[] args) { // Create a LinkedList LinkedList<String> linkedlist = new LinkedList<String>(); // Add elements to LinkedList linkedlist.add("Cobol"); linkedlist.add("JCL"); linkedlist.add("C++"); linkedlist.add("C#"); linkedlist.add("Java"); // Displaying Elements before replace System.out.println("Before Replace:"); for(String str: linkedlist){ System.out.println(str); } // Replacing 3rd Element with new value linkedlist.set(2, "NEW VALUE"); System.out.println("\n3rd Element Replaced \n"); // Displaying Elements after replace System.out.println("After Replace:"); for(String str2: linkedlist){ System.out.println(str2); } } } ``` 輸出: ```java Before Replace: Cobol JCL C++ C# Java 3rd Element Replaced After Replace: Cobol JCL NEW VALUE C# Java ```
                  <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>

                              哎呀哎呀视频在线观看