I want to remove the element if it is present in a linkedlist while iterating over an array of numbers
for(int num : numbers)
{
if(l.contains(num))
{
l.remove(num);
}
}
However, it is trying to remove element at index num, instead of looking for num in the linked list.
The javadoc has this method
remove(Object o)
Removes the first occurrence of the specified element from this list, if it is present.
How to use it?