Find Vector : Vector « Collections Data Structure « Java

Find Vector

```

import java.util.Vector;

public class FindVector2 {
static String members[] = { "Ralph", "Waldo", "Emerson", "Henry", "David",
"Thoreau", "Walden", "Pond", "Thoreau", "Institute" };

public static void main(String args[]) {
Vector v = new Vector();
for (int i = 0, n = members.length; i < n; i++) {
}
System.out.println(v);
System.out.println("Contains Society?: " + v.contains("Society"));
System.out.println("Contains Waldo?: " + v.contains("Waldo"));
System.out.println("Where's Waldo?: " + v.indexOf("Waldo"));
System.out.println("Where's Thoreau?: " + v.indexOf("Thoreau"));
System.out.println("Where's Thoreau from end?: "
+ v.lastIndexOf("Thoreau"));
int index = 0;
int length = v.size();
while ((index < length) && (index >= 0)) {
index = v.indexOf("Thoreau", index);
if (index != -1) {
System.out.println(v.get(index));
index++;
}
}
}
}

```

Related examples in the same category

 1 Use Vector in java.util 2 Finding elements in a vector 3 Serializing a vector 4 Save Vector to file 5 Create Vector test 6 Remove Element in Vector 7 Sequence 8 Vector Util 9 Iterator out of Vector 10 Copy Elements of One Java Vector to Another Java Vector 11 Copy Elements of Vector to Java ArrayList 12 Create Java ArrayList From Enumeration 13 Find maximum element of Java Vector 14 Find Minimum element of Java Vector 15 Get Enumeration over Java Vector 16 Perform Binary Search on Java Vector 17 Replace All Elements Of Java Vector 18 Replace all occurrences of specified element of Java Vector 19 Reverse order of all elements of Java Vector 20 Shuffle elements of Java Vector 21 Swap elements of Java Vector 22 Sort Java Vector in descending order using comparator 23 Enumerate through a Vector using Java Enumeration 24 Append all elements of other Collection to Java Vector 25 Copy all elements of Java Vector to an Object Array 26 Get Size of Java Vector and loop through the elements 27 Get Sub List of Java Vector Example 28 Insert all elements of other Collection to Specified Index of Java Vector 29 Iterate through elements Java Vector using Iterator 30 Iterate through elements Java Vector using ListIterator 31 Remove all elements from Java Vector 32 Remove an element from specified index of Java Vector 33 Remove specified element from Java Vector 34 Replace an element at specified index of Java Vector 35 Search an element of Java Vector 36 Search an element of Java Vector from specific index 37 Set size of Java Vector Example 38 Sort elements of Java Vector 39 Generic Vector with String 40 Count distinct elements in a Vector 41 Unmodifiable Vector Adapter 42 Adaptive extension of the java.util.Vector class