3:12 am - Friday July 20, 2018

Add object to an ArrayList boolean add(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

BACK

                          An array is used to store the collection of data. add( ) method is used to add element in the list to store the data.

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);

            }
       }
 }

Output

   Enter the details

   name

   age

   email

BACK

Filed in: Java Examples

Comments are closed.