❮ Previous Next ❯

ListIterator

Methods in ListIterator:

let's see a simple program to better understand these concepts easily.

Example: ListIteratorDemo.java

importjava.util.*;
classListIteratorDemo
{
public static void main(String args[])
{
LinkedList l=new LinkedList();
l.add("Sidhant");
l.add("Anubhav");
l.add("Babushan");
l.add("Arindam");
System.out.println(l);
ListIterator li=l.listIterator();
while(li.hasNext())
{
String s=(String)li.next();
if(s.equals("Arindam"))
{
li.remove();
}
else
if(s.equals("Babushan"))
{
li.add("Amlan");
}
else
if(s.equals("Anubhav"))
{
li.set("Budhaditya");
}
}
System.out.println(l);
}
}
Output:

[Sidhant, Anubhav, Babushan, Arindam]
[Sidhant, Budhaditya, Babushan, Amlan]

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved