ListIterator : add()

The add() method is used to add objects to a collection. This method always takes an object as an argument. If we wish to store primitive data type values, we have to convert them into objects and then add them to the collection. Program       Program Source import java.util.ArrayList; import java.util.ListIterator; public class … Read more…

ListIterator : hasNext(), next(), hasPrevious() and previous()

ListIterator is used just like Iterator. For collections that implement List, you can also obtain an iterator by calling listIterator(). A list iterator gives you the ability to access the collection in either the forword or backword direction and lets you modify an element. The hasPrevious( ) method returns true if there is a previous … Read more…