4:15 am - Thursday July 19, 2018

ArrayList Example Program for removeRange(int fromIndex, int toIndex)

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
removeRange(int fromIndex, int toIndex).It is used to  remove element from between given index range values
*/
import java.io.*;
import java.util.*;
public class AryListRemoveIndexFrom extends ArrayList
{
public static void main(String arg[])throws Exception
{
AryListRemoveIndexFrom al=new AryListRemoveIndexFrom();//to create object for ArrayList class
al.add("w");//to add an element in arrayList
al.add("e");//to add an element in arrayList
al.add("l");//to add an element in arrayList
al.add("l");//to add an element in arrayList
al.add("d");//to add an element in arrayList
al.add("c");//to add an element in arrayList
al.add("o");//to add an element in arrayList
al.add("m");//to add an element in arrayList
al.add("e");//to add an element in arrayList
System.out.println(al);
al.removeRange(3,5);//to remove elements from between given index range values
System.out.println("after remove element in index 2:"+al);
}
}

Output:
[w, e, l, l, d, c, o, m, e]
after remove element in index 2:[w, e, l, c, o, m, e]

BACK

Filed in: Z-A All Java Codes

Comments are closed.