Vector: contains(Object obj) : Vector « java.util « Java by API






Vector: contains(Object obj)

  
/**
 *Output: 
Initial size: 0
Initial capacity: 3
First element: 1
Last element: 2
*/

import java.util.Vector;

public class MainClass {
  public static void main(String args[]) {

    // initial size is 3, increment is 2
    Vector<Integer> v = new Vector<Integer>(3, 2);

    System.out.println("Initial size: " + v.size());
    System.out.println("Initial capacity: " + v.capacity());

    v.addElement(1);
    v.addElement(2);

    System.out.println("First element: " + v.firstElement());
    System.out.println("Last element: " + v.lastElement());

    if (v.contains(3))
      System.out.println("Vector contains 3.");
  }
}

           
         
    
  








Related examples in the same category

1.new Vector(Collection c)
2.Vector: addElement(E e)
3.Vector: add(T e)
4.Vector: clear()
5.Vector: containsAll(Collection c)
6.Vector: copyInto(Object[] anArray)
7.Vector: capacity()
8.Vector: elementAt(int index)
9.Vector: elements()
10.Vector: ensureCapacity(int minCapacity)
11.Vector: equals(Object o)
12.Vector: firstElement()
13.Vector: get(int index)
14.Vector: hashCode()
15.Vector: indexOf(Object o)
16.Vector: indexOf(Object o, int index)
17.Vector: insertElementAt(E obj, int index)
18.Vector: isEmpty()
19.Vector: iterator()
20.Vector: lastElement()
21.Vector: lastIndexOf(Object o)
22.Vector: lastIndexOf(Object o, int index)
23.Vector: listIterator()
24.Vector: remove(int index)
25.Vector: remove(Object o)
26.Vector: removeAllElements()
27.Vector: removeAll(Collection c)
28.Vector: removeElementAt(int index)
29.Vector: removeElement(Object obj)
30.Vector: retainAll(Collection c)
31.Vector: set(int index, Object element)
32.Vector: setSize(int newSize)
33.Vector: size()
34.Vector: subList(int fromIndex, int toIndex)
35.Vector: toArray()
36.Vector: toArray(T[] a)
37.Save Vector to File