import java.util.*;
public class list<E> extends LinkedList<E> {
int j=0;
int l=0;
LinkedList Search(Object o) {
int[] array=new int[super.size()];
for(int i=0; i<super.size(); i++) {
if(o.equals(super.get(i))) {
array[j]=i;
j=j+1;
continue;
}
}
return Arrayfilter(array);
}
private LinkedList Arrayfilter(int[] i) {
int[] aray=null;
LinkedList<Integer> ll= new LinkedList<Integer>();
for(int j:i){
if((l==0)|(j!=0)){
ll.add(j);
l=l+1;
continue;
}
}
return ll;
}
boolean deleteduplicate() {
for(int l=0; l<super.size(); l++){
for(int i:Search(super.get(l))) {
super.remove(i);
}
}
return true;
}
}
Whenever I tried that method delete duplicate () it gives me index out of bounds error how I can modify the method that it return true
I know that whenever I remove anything in for loop I reducing the size of list that giving me that error, or anything else?