4:36 pm - Saturday September 23, 2017

LinkedList Example Program for addAll(int index, Collection c)

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
/*Program Name: LinkedList Example Program for addAll using int index, Collection c*/
/**
*@Author: Candidjava.com
*@Description:LinkedList Example Program for addAll (int index, Collection c)
  Program is used to Inserts all of the elements in the specified collection into this list,
  starting at the specified position.
*/
import java.util.*;

public class CollectionList1
{
 public static void main(String args[])
 {
  LinkedList<String> ll=new LinkedList<String>(); //creating linkedlist objects.
  LinkedList<String> lList=new LinkedList<String>();
  ll.add("john"); //initialize ll and adding elemnts.
  ll.add("babu");
  ll.add("k");
  lList.add("computer"); //initialize lList and adding elements.
  lList.add("science");
  lList.add("engineer");
  lList.addAll(2,ll); // adding all the elements from ll to lList starting at index 2.
  System.out.println("AddAll elements are:"+lList); //printing the result.
 }
}

Output:

AddAll elements are:[computer, science, john, babu, k, engineer]


BACK

Filed in: Z-A All Java Codes

Comments are closed.