Java ListIterator remove() Method22 Mar 2025 | 2 min read The remove() method of ListIterator interface is used to remove the last element from the list which is returned by next() or previous() method. The above method can only be called if the add(E) has not been called. SyntaxParametersNA Specified by:remove in interface Iterator<E> ReturnNA Throws:UnsupportedOperationException- If the given remove operation is not supported by the list iterator. IllegalStateException- If neither the next() nor the previous() method has been called. Example 1Output: The list for the vehicles is given as :[Car, Truck, Bike, Cycle] Before remove() method is called. : [Car, Truck, Bike, Cycle] After remove() method is called.: [Car, Bike, Cycle] Example 2Output: The list for the marks is given as :[55.0, 69.0, 78.0, 89.0] Before remove() method is called. : [55.0, 69.0, 78.0, 89.0] After remove() method is called.: [55.0, 78.0, 89.0] Example 3Output: The list for the ages is given as :[25, 30, 35, 40, 45] Before remove() method is called. : [25, 30, 35, 40, 45] After remove() method is called.: [25, 35, 40, 45] Next TopicJava ListIterator |
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India