I've tried to find some information about differences between pop(), poll() and remove() in LinkedList but unfortunately I didn't find out any precision answer. The only information I have got was that:
-pop() removes first element of the list and throws exception if the list is empty -remove() works the same as pop() -poll() removes first element of the list but if the list is empty return null
And here's my question. Is it true that remove() and pop() have one small difference that I can add an Index to remove method? For example list.remove(3). I see that it is impossible to do with pop()
LinkedList<Integer> list = new LinkedList<>();
list.push(1);
list.push(2);
list.push(3);
list.push(4);
list.push(5);
```
list.pop(); //Output: 4, 3, 2, 1
//or
list.poll(); //Output: 4, 3, 2, 1
//or
list.remove(3); //Output: 5, 4, 3, 1