java.util.Vector.remove(Object o) 方法示例


java.util.Vector.remove(Object o) 方法示例

package com.codingdict;

import java.util.Vector;

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

      // create an empty Vector vec with an initial capacity of 6     
      Vector<Integer> vec = new Vector<Integer>(6);

      // use add() method to add elements in the vector
      vec.add(33);
      vec.add(34);
      vec.add(22);
      vec.add(11);
      vec.add(22);
      vec.add(12);

      // let us remove the 1st element
      System.out.println("Removed element: "+vec.remove((Integer)22));     

      // lets print the elements
      System.out.println("The elements in the vector are:");     

      for (Integer number : vec) {         
         System.out.println("Number = " + number);
      }
   }    
}