Click here to watch in Youtube : https://www.youtube.com/watch?v=kvtH4b6UO_A
LinkedListAddIndexBasedExample.java
import java.util.LinkedList; /* * Example of add(int index, E element) method */ public class LinkedListAddIndexBasedExample { public static void main( String[] args ) { LinkedList<Integer> linkedList = new LinkedList<Integer>(); linkedList.add(1); linkedList.add(2); linkedList.add(3); System.out.println("linkedList : " + linkedList); /* * In Position 2 adding 10 */ linkedList.add(2, 10); System.out.println("linkedList : " + linkedList); } }
linkedList : [1, 2, 3] linkedList : [1, 2, 10, 3]
https://sites.google.com/site/javaee4321/java-collections/LinkedListDemoAddIndex.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment