10:38 pm - Monday May 21, 2018

ArrayList Example Program for remove(int index)

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
remove(int index).It is used to  remove an element from list by using index value
*/
import java.io.*;
import java.util.*;
public class ArrayListRemoveIndex
{
public static void main(String arg[])throws Exception
{
ArrayList al=new ArrayList();//to create object for ArrayList class
al.add("best");//to add an element in arrayList
al.add("good");//to add an element in arrayList
al.add("poor");//to add an element in arrayList
System.out.println(al);
al.remove(2);//to remove an element from list by using index value
System.out.println("after remove element in index 2:"+al);
}
}

Output:
[best, good, poor]
after remove element in index 2:[best, good]

BACK

Filed in: Z-A All Java Codes

Comments are closed.