Friday, July 22, 2011

vector (some function of vector)

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package vectortest;

import java.util.Scanner;
import java.util.Vector;

/**
*
* @author LLynAs
*/
public class VectorTest {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Vector v=new Vector();
v.addElement("hello");
v.add("hi");
v.add("bye");

System.out.println(v);

for(Object element: v){

System.out.println(element);

}

System.out.println(v.elementAt(0));
System.out.println(v.capacity());

Scanner ip=new Scanner(System.in);
// System.out.println("Enter here::");
// for(int i=0;i<5;i++){
// v.add(ip.next());
// }
// for(Object element: v){
//
// System.out.println(element);
//
// }
v.removeElement("helo");
v.removeElementAt(0);



System.out.println(v.indexOf("hi",1));
}
}