LinkedList from scratch, replacing a node
<p>I was given an assignement to create a LinkedList from scratch, I've figured how to code a method that add a node at the end of the list but I still can't figure how to replace a node. Here is what I have so far:</p>

<pre><code>public boolean replace(int element, int index) {
        Node temp= new Node(pElement);
        Node current = getHead();
        if (!isEmpty()) {
            for (int i = 0; i &lt; index &amp;&amp; current.getNext() != null; i++) {
                current = current.getNext();
            }
            temp.setNext(noeudCourant.getNext());
            noeudCourant.setNext(temp);

            listCount++;
            return true;
        }
        return false;
    }
</code></pre>

<p>Using <em>aNode.replace(10, 4)</em> on  "0 1 2 3 4 5 6 7 8 9 10"</p>

<p>will make it into</p>

<blockquote>
  <p>[0]->[1]->[2]->[3]->[4]->[<strong>10</strong>]->[5]->[6]->[7]->[8]->[9]->[10]</p>
</blockquote>

<p>but I want:</p>

<blockquote>
  <p>[0]->[1]->[2]->[3]->[<strong>10</strong>]->[5]->[6]->[7]->[8]->[9]->[10]</p>
</blockquote>

<p>Any help is appreciated.</p>

<p>[edit]I already have a working method setData() but the assignment I have forbid me to use it. What I want is basically this:</p>

<p><a href="http://i.imgur.com/oOVYCvc.png" rel="nofollow">http://i.imgur.com/oOVYCvc.png</a></p>