8:05 am - Sunday August 20, 2017

Vector Example Program for get(int index)

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

// Vector Example Program for get(int index)
/**
@author: candidjava.com
@description: This program returns the element at the specified index in the Vector.
*/

import java.util.*;

public class Get {
public static void main(String[] args) {
Vector v = new Vector(); // Creating a new vector
// adding strings to the vector
v.add("This");
v.add("is");
v.add("chennai");
for (Object o : v) {
System.out.println(o);
}
Object ob = v.get(2); // Get the element at the specified index
System.out.println("The name of the city is:  " + ob);
}
}


output:
This
is
chennai
The name of the city is:  chennai

Filed in: Z-A All Java Codes

Comments are closed.