12:11 am - Monday June 25, 2018

Stack 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 StackRemoveIndexFrom extends Stack
{
public static void main(String arg[])throws Exception
{
StackRemoveIndexFrom s=new StackRemoveIndexFrom();//to create object for Stack class
s.add("1");//to add an element in Stack
s.add("2");//to add an element in Stack
s.add("3");//to add an element in Stack
s.add("4");//to add an element in Stack
s.add("4");//to add an element in Stack
s.add("5");//to add an element in Stack
s.add("6");//to add an element in Stack
s.add("7");//to add an element in Stack
s.add("8");//to add an element in Stack
System.out.println(s);
s.removeRange(3,5);//to remove elements from between given index range values
System.out.println("after remove element in index 2:"+s);
}
}

OUTPUT:
[1, 2, 3, 4, 5, 6, 7, 8]
after remove element in index 2:[1, 2, 3, 5, 6, 7, 8]

BACK

Filed in: Z-A All Java Codes

Comments are closed.