?? vectortest.java~3~
字號:
package vectortest;
import java.util.*;
import java.awt.*;
public class VectorTest {
Vector sam=new Vector(15,3);
public VectorTest()
{
System.out.println("The vector's init capacity is:"+sam.capacity());
System.out.println("The vector's init size is:"+sam.size());
System.out.println("Insert 0-9 Vector");
for(int i=0;i<10;i++)
sam.addElement(new Integer(i));
System.out.println("The vector's capacity is:"+sam.capacity());
System.out.println("The vector's size is "+sam.size());
System.out.println("Insert button0-button9 to Vector");
for(int i=0;i<10;i++)
{
Button button=new Button("button"+Integer.toString(i));
sam.addElement(button);
}
System.out.println("The vector's capacity is:"+sam.capacity());
System.out.println("The vector's size is:"+sam.size());
int index=sam.indexOf(new Integer(6));
System.out.print("The index of 6 in the vector is:"+index);
int firstNumber=((Integer)sam.firstElement()).intValue();
System.out.println("The first element int the vector's is:"+firstNumber);
Button button=(Button)sam.lastElement();
System.out.println("The last element in the vector is:"+button.getLabel());
System.out.println("Remove 4 element in the vector");
for (int i=8;i<12;i++)
sam.removeElementAt(i);
System.out.println("The vector's capacity is:"+sam.capacity());
System.out.println("The vector's size is:"+sam.size());
System.out.println
("Trim the vector to size ");
sam.trimToSize();
System.out.println("The vector's capacity is:"+sam.capacity());
System.out.println("The vactor's size is :"+sam.size());
System.out.println("Remove all element of the vector");
sam.removeAllElements();
System.out.println("The vector's capacity is:"+sam.capacity());
System.out.println("The vector's size if:"+sam.size());
sam.trimToSize();
System.out.println("Trim the vector to size");
System.out.println("The vecotr's last capacity is:"+sam.capacity());
System.out.println("The vector's last sizeis:"+sam.size());
} //end of VectorTest()
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -