I want to remove list item with value 5 from the list. I do not want to remove it based on index since values added to the list are random.
List<Integer> list = new ArrayList<>();
list.add(3); //adding the value
list.add(1);
list.add(5);
list.add(4);
sukanya meruva Answered question
We can remove the value from list with out using index using remove() method. Since We need remove the value 5, we can do it as follows:
list.remove(Integer.valueOf(5)); //removal of value 5
sukanya meruva Answered question