1:39 pm - Tuesday August 21, 2018

LinkedList example program for add()

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
*@descriptions : This program explain the function and use of LinkedList add() method
*/
import java.util.LinkedList;

class LinkedList {
	public static void main(String[] args) {
		// creating LinkedList Object
		LinkedList lList = new LinkedList();
		// Linked list add() method is used to insert the elements in a list
		lList.add("1");
		lList.add("2");
		lList.add("3");
		lList.add("4");
		lList.add("5");
		System.out.println("LinkedList contains : " + lList);
	}
}

Output:

D:\CandidJava\Util\LinkedList>javac LinkedList1.java

Note: LinkedList1.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

D:\CandidJava\Util\LinkedList>java LinkedList1

LinkedList contains : [1, 2, 3, 4, 5]   

 

BACK

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply