7:33 am - Monday September 24, 2018

ArrayList Example Program for add(int index, E element)

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
void add(E e).It is used to add an element in specified index of arrayList
*/
import java.io.*;
import java.util.*;
public class ArrayListAppends
{
public static void main(String arg[])throws Exception
{
ArrayList E=new ArrayList();//to create object for ArrayList class
E.add(12);//to add an element in arrayList
E.add(10);//to add an element in arrayList
E.add(6);//to add an element in arrayList
E.add(2,5);//to add an element in specified index of arrayList
System.out.println(E);
}
}

Output:
[12, 10 ,5 ,6]

BACK

Filed in: Z-A All Java Codes

Comments are closed.