Example usage for java.util Vector lastIndexOf

List of usage examples for java.util Vector lastIndexOf

Introduction

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

Prototype

public synchronized int lastIndexOf(Object o, int index) 

Source Link

Document

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

Usage

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(6);

    vec.add(6);//  w  w w . ja  va2 s  .  com
    vec.add(5);
    vec.add(4);
    vec.add(3);
    vec.add(2);
    vec.add(1);

    System.out.println("index is: " + vec.lastIndexOf(1, 4));
}

From source file:Main.java

public static void main(String[] args) {
    Vector<String> v = new Vector<String>();
    v.add("1");//from  w  w w.  ja  v a 2  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));
}