9:08 am - Thursday February 22, 2018

Vector Example Program for setSize(int newSize)

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: setSize(int newSize) is used to Sets the size of this vector.
 */
import java.util.*;

public class DeeSetSizeVector {
	public static void main(String[] args) {
		Vector v = new Vector();// create the vector
		v.add('c');// add the elements
		v.add('a'); // add the elements
		v.add('n'); // add the elements
		v.add('d'); // add the elements
		v.add('i'); // add the elements
		v.add('d'); // add the elements
		System.out.println("the elements are: " + v);// to print the elements
		v.setSize(9);// to set the size in this vector,
			//the remaining field fill in null values
		System.out.println("the new elements are: " + v);// to print the
					// elements
	}
}

Output:
the elements are: [  c, a, n, d, i, d]
the new elements are: [  c, a, n, d, i, d, null, null, null]



Filed in: Z-A All Java Codes

Comments are closed.