3:04 am - Friday April 19, 2019

LinkedList Example Program for add(int index, E element)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
Author :candidjava.com
Description: Inserts the specified element at the specified position in this list.
 */
import java.io.IOException;
import java.util.*;
import java.io.IOException;

public class LinkedlistAddExample2 {
	public static void main(String args[]) throws IOException {
		// boolean a;
		int b = 2;
		LinkedList l = new LinkedList();
		l.add(1, b);// add b to the list in the 1st position
		System.out.println(b + "is added to the list");
	}
}


Output
2 is added to the list

Filed in: Z-A All Java Codes

Comments are closed.