vectorcl.java

来自「this is an online shopping project」· Java 代码 · 共 29 行

JAVA
29
字号
import java.util.*;

class vectorcl{
  public static void main(String args[]){
   Vector v=new Vector(3,2);
   System.out.println("size:"+v.size());
   System.out.println("capacity:"+v.capacity());
   v.addElement(new Integer(1));
   v.addElement(new Integer(2));
   v.addElement(new Integer(3));
   v.addElement(new Integer(4));
   System.out.println("capacity after four additions:"+v.capacity());
  v.addElement(new Double(3.25));
  System.out.println("current capacity:"+v.capacity());
  v.addElement(new Float(7.5));
  v.addElement(new Integer(1));
  System.out.println("current capacity:"+v.capacity());
  System.out.println("Firstelement:"+(Integer)v.firstElement());
 System.out.println("Lastelement:"+(Integer)v.lastElement());
if(v.contains(new Integer(1)))
  System.out.println("contains 1");
Iterator it=v.iterator();
System.out.println("\n elements in vector:");
while(it.hasNext())
  System.out.print(it.next()+" ");
  System.out.println();
 }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?