How to Add element at specific index in LinkedList ?

rencontre amoureuse gratuite a la reunion In this example we have a LinkedList of Strings and we are adding an element to its 5th position(4th index) using add() method. The complete code is as follows:

rencontre assyriologique internationale 2015

http://thinkmaya.com/?biorer=site-de-rencontre-pour-sortie-amicale&73d=86 package linkedlist; import java.util.Iterator; import java.util.LinkedList; public class AddElement { public static void main(String[] args) { // Create a LinkedList LinkedList<String> linkedlist = new LinkedList<String>(); // Add elements to LinkedList linkedlist.add("Delhi"); linkedlist.add("Agra"); linkedlist.add("Mysore"); linkedlist.add("Chennai"); linkedlist.add("Pune"); System.out.println("**LinkedList elements Before Addition:"); Iterator<String> i= linkedlist.iterator(); while(i.hasNext()){ System.out.println(i.next()); } // Adding new Element at 5th Position linkedlist.add(4, "NEW ELEMENT"); // Iterating the list in forward direction System.out.println("**LinkedList elements After Addition:"); Iterator<String> it= linkedlist.iterator(); while(it.hasNext()){ System.out.println(it.next()); } } }

rencontres séniors 51 como conocer un hombre mentiroso Output:

http://www.bicialpedrete.es/?okno=hombre-solo-busca-empleada-domestica&261=b3

https://distillery244.com/frnew1/6741 **LinkedList elements Before Addition:
Delhi
Agra
Mysore
Chennai
Pune
**LinkedList elements After Addition:
Delhi
Agra
Mysore
Chennai
NEW ELEMENT
Pune

visit our website