8:17 pm - Saturday April 20, 2019

Vector Example Program for setElementAt(E obj,int index)

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: setElementAt(E obj,int index) is used to Sets the component at the specified index of this vector to be the specified object.
import java.util.*;

public class DeeSetElementsVector {
	public static void main(String[] args) {
		Vector v = new Vector();// create the vector
		v.add("welcome");// add the element
		v.add("to");// add the element
		v.add("candid");// add the element
		System.out.println("the statement is: " + v);// to print the elements
		v.setElementAt("java", 2);// set the new elements with existing elements
		System.out.println("After set the elements");
		System.out.println("the new statement is: " + v);// to print the new
							// strings

the statement is: [welcome, to, candid]
After set the elements
the new statement is: [welcome, to, java]

Filed in: Z-A All Java Codes

Comments are closed.