12:50 am - Thursday July 27, 2017

Add all object from another Collection boolean addAll(collectionc)

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

BACK

                                This method is used to add All object to ArrayList from another Collection Objects.

Example Program

import java.util.ArrayList;

public class Fun 
{

    public static void main(String[] args)

    {

        ArrayList<String> Student=new ArrayList<String>();

        Student.add("name:");

        Student.add("age:");

        Student.add("email:");

        System.out.println("Enter the details");

        for (String Name:Student)

          {

            System.out.println(Name);

          }

        ArrayList<String> Student1=new ArrayList<String>();

        Student1.add("date of birth:");

        Student1.add("id:");

        Student1.add("college name:");

        Student1.add("verification code:");

        System.out.println("Enter the student verification details");

        for (String Name:Student1)

        {

            System.out.println(Name);

        }

        Student.addAll(Student1);

        System.out.println("\n"+"Print all the details:"+" "+"\n");

        for (String s1 : Student) 
          {

        System.out.println(s1);

           }
     }
}

Output

   Enter the details

   name:

   age:

   email:

   Enter the student verification details

   date of birth:

   id:

   college name:

   verification code:

   Print all the details:

   name:

   age:

   email:

   date of birth:

   id:

   college name:

   verification code:

BACK

Filed in: Java Examples

Comments are closed.