10:15 am - Wednesday December 19, 2018

Vector Example Program for set(int index,E element)

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: set(int index,E element) is used to Replaces the element at the specified position in this Vector with the specified element.
 */
import java.util.*;

public class DeeSetVector {
	public static void main(String[] args) {
		Vector v = new Vector();// create the vector
		v.add("welcome");// add the elements
		v.add("to");// add the elements
		v.add("candid");// add the elements
		System.out.println("the statement is: " + v);// to print the elements
		v.set(2, "java");// to enter the replace element and index
		System.out.println("After set");
		System.out.println("the new statement is: " + v);// to print the new
					// elements
	}
}

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

Filed in: Z-A All Java Codes

Comments are closed.