I have the following code:
public static void poistaKaikki32(LinkedList L1, Collection L2) {
LinkedList<Integer> temp = new LinkedList<>();
HashSet<Integer> L2Set = new HashSet<>(L2);
// first filter elements into temp
while (L1.size() > 0) { // n loops
int v = L1.removeFirst(); <--- getting error cannot convert object to int
if (!L2Set.contains(v)) {
temp.addLast(v);
}
}
// add filtered values back to L1
while (temp.size() > 0) {
L1.addLast(temp.removeFirst());
}
}
I keep getting an error on int v = L1.removeFirst();. How would i fix this, without using casts.