I have a List with some elements. My method get random element from List like
ListName.get(num)
How can I remove element from List with that num I've got?
Asked
Active
Viewed 142 times
-6

Mark Rotteveel
- 100,966
- 191
- 140
- 197

Pirvet
- 1
- 2
-
`ListName.remove(num)`. – Unmitigated Jul 13 '20 at 19:01
-
Did you try `listname.remove(num)`? – khelwood Jul 13 '20 at 19:01
-
Does this answer your question? [Removing item from generic list java?](https://stackoverflow.com/questions/26567815/removing-item-from-generic-list-java) – PiRocks Jul 13 '20 at 19:07
-
2Hello, and welcome! If you're wondering why this question has received downvotes, it may be because the answer can be found by reading the [documentation for the List interface](https://docs.oracle.com/javase/8/docs/api/java/util/List.html). – dnault Jul 13 '20 at 19:13
2 Answers
2
Call List::remove
and pass the same number.
myList.remove( num ) ;

Basil Bourque
- 303,325
- 100
- 852
- 1,154