import java.util.Vector;
public class GetElement {
public static void main(String[] args) {
Vector<String> vector = new Vector<String>();
//add element in vector
vector.add("cricket");
vector.add("hockey");
vector.add("football");
vector.add("tennish");
// print vector
System.out.println("Vector = "+vector);
/*
* Returns the element at the specified
* position in this Vector.
*/
System.out.println("element at index 2 is = "+vector.get(2));
}
}
Output:
Vector = [cricket, hockey, football, tennish]
element at index 2 is = football
No comments:
Post a Comment