2:22 am - Tuesday November 13, 2018

sample program using ArrayList add() method

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
sample program using Array list add() method Program
Coding:

/**

*@author :CandidJava.com

*@date :12/12/2011

*@descriptions : This program explain the function and use of ArrayList add() method

*/

import java.util.*;

class ArrayListAdd {

public static void main(String args[]) {

//creating ArrayList Object

ArrayList al=new ArrayList();

// ArrayList add method will insert the data based on their index position

al.add("hai");

al.add("java");

al.add("welcome");

al.add(4);

//Displays the elements in Arraylist

System.out.println(al);

}

}

output:

D:\ code>java>util>ArrayList>javac ArrayListDemo.java

Note: ArrayListDemo.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

D:\ code>java>util>ArrayList>java ArrayListDemo

[hai, java, welcome, 4]

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply