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){
34
34
}
35
35
36
36
public E remove (int pos ){
37
- if (pos >size || pos < 0 ){
37
+ if (pos >= size || pos < 0 ){
38
38
//catching errors
39
39
throw new IndexOutOfBoundsException ("position cannot be greater than size or negative" );
40
40
}
@@ -45,13 +45,15 @@ public E remove(int pos){
45
45
iterator = iterator .next ;
46
46
before = before .next ;
47
47
}
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.
50
50
before .next = iterator .next ;
51
51
// scrubbing
52
52
iterator .next = null ;
53
53
iterator .value = null ;
54
+ size --;
54
55
55
- return saved ;
56
+ return removedValue ;
56
57
}
58
+
57
59
}
You can’t perform that action at this time.
0 commit comments