2:22 am - Friday April 19, 2019

LinkedList Example Program for addFirst(E e)

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: To Inserts the specified element at the beginning of this list.
 */
import java.io.IOException;
import java.util.*;
import java.io.IOException;

public class LinkedListAddFirst {
	public static void main(String args[]) throws IOException {
		int b = 2;
		LinkedList l = new LinkedList();
		l.addFirst(b);// add 2 as a first element in the list
		System.out.println(b + "is added as a first element in the list");
	}
}

Output
2 is added as a first element in the list

Filed in: Z-A All Java Codes

Comments are closed.