10:47 am - Thursday January 19, 2017

Replace an element present in a Vector E 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

BACK

                    The public E set(int index, E element) method Replaces the element at the specified position in this Vector with the specified element.

Example program

import java.util.Vector;

public class VectorSet 

{

	public static void main(String[] args)

	{

		Vector h = new Vector();

		h.add("Happy");

		h.add("Birthday");

		System.out.println("the statement is: " + h);

		h.set(1, "b'day");

		System.out.println("After set");

		System.out.println("the new statement is: " + h);
	}
}

Output

   the statement is: [Happy, Birthday]

   After set

   the new statement is: [Happy, b’day]

BACK

Filed in: Java Examples

Comments are closed.