Vector IndexOf
  • Note vector allows duplication, therefore the duplicate data will have same index value.
Example

import java.io.*;
import java.util.*;// Arrays.sort
public class Test_This {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
Process p1 = new Process();
p1.method_1();
}
}
class Process
{
String first[] = {"Java","A+","C#","XML","JSP","PHP","Z", "C#"};
public Process()
{
System.out.println("Default) constructor");
}
public void method_1()
{
Vector vt = new Vector();
String mystring, str="";
for (String s : first)
{
vt.add(s);
System.out.println(vt.indexOf(s)+ "\t" +s);
}
System.out.println(vt);
//System.out.println(vt.remove(4));
}
}