3:42 pm - Friday November 18, 0692

Vector 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
@description: removeRange(int fromIndex,int toIndex) is used to Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.
 */
import java.util.*;

public class DeeRemoveRange {
	public static void main(String[] args) {
		Vector v = new Vector();// create the vector
		v.add('d');// add the elements
		v.add('e'); // add the elements
		v.add('e'); // add the elements
		v.add('p'); // add the elements
		v.add('a'); // add the elements
		v.add('n'); // add the elements
		v.add('r'); // add the elements
		v.add('a'); // add the elements
		v.add('j'); // add the elements
		System.out.println("the elements are: " + v);// to print the vector
								// elements
		v.subList(3, 6).clear();// to remove the elements between from index,
					//to index
		System.out.println("after removed");
		System.out.println("the new elements are: " + v);// to print the new
								// elements
	}
}

output
the elements are: [d, e, e, p, a, n, r, a, j]
after removed
the new elements are: [d, e, e, r, a, j]

Filed in: Z-A All Java Codes

Comments are closed.