Example usage for java.util Vector indexOf

List of usage examples for java.util Vector indexOf

Introduction

In this page you can find the example usage for java.util Vector indexOf.

Prototype

public synchronized int indexOf(Object o, int index) 

Source Link

Document

Returns the index of the first occurrence of the specified element in this vector, searching forwards from index , or returns -1 if the element is not found.

Usage

From source file:Main.java

public static void main(String[] args) {
    Vector<String> v = new Vector<String>();
    v.add("1");//from w  w w.j a va2  s.co  m
    v.add("2");
    v.add("3");
    v.add("4");
    v.add("5");
    v.add("1");
    v.add("2");

    System.out.println(v.indexOf("1", 4));
    System.out.println(v.lastIndexOf("2", 5));
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    vec.add(4);/* www  . ja v  a  2 s  .  c  o m*/
    vec.add(3);
    vec.add(2);
    vec.add(3);
    vec.add(2);
    vec.add(3);

    /** let us get the index of 3
     * starting search from 2nd index
     */
    System.out.println("Index of 3 :" + vec.indexOf(3, 2));
}