File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public void append(E value){
3434 }
3535
3636 public E remove (int pos ){
37- if (pos >size || pos < 0 ){
37+ if (pos >= size || pos < 0 ){
3838 //catching errors
3939 throw new IndexOutOfBoundsException ("position cannot be greater than size or negative" );
4040 }
@@ -45,13 +45,15 @@ public E remove(int pos){
4545 iterator = iterator .next ;
4646 before = before .next ;
4747 }
48- E saved = iterator .value ;
49- // assigning the next referance to the the element following the element we want to remove... the last element will be assigned to the head.
48+ E removedValue = iterator .value ;
49+ // assigning the next reference to the the element following the element we want to remove... the last element will be assigned to the head.
5050 before .next = iterator .next ;
5151 // scrubbing
5252 iterator .next = null ;
5353 iterator .value = null ;
54+ size --;
5455
55- return saved ;
56+ return removedValue ;
5657 }
58+
5759}
You can’t perform that action at this time.
0 commit comments