title: How to replace existing value of ArrayList element in Java
body: <p>I am still quite new to Java programming and I am trying to update an existing value of an <code>ArrayList</code> by using this code:</p>
  
  <pre><code>public static void main(String[] args) {
  
      List&lt;String&gt; list = new ArrayList&lt;String&gt;();
  
      list.add( "Zero" );
      list.add( "One" );
      list.add( "Two" );
      list.add( "Three" );
  
      list.add( 2, "New" ); // add at 2nd index
  
      System.out.println(list);
  }
  </code></pre>
  
  <p>I want to print <code>New</code> instead of <code>Two</code> but I got <code>[Zero, One, New, Two, Three]</code> as the result, and I still have <code>Two</code>. I want to print <code>[Zero, One, New, Three]</code>. How can I do this?
  Thank You.</p>