中文字幕综合一区,伊人av网,欧美中日韩在线,亚洲国产香蕉视频,黄视频在线免费,天天操天天爱天天爽,狠狠躁天天躁

軟題庫 移動APP 掃碼下載APP 隨時隨地移動學習 培訓課程
試卷名稱 2008年下半年程序員考試下午真題試題(案例分析)
考試中心《2008年下半年程序員考試下午真題試題(案例分析)》在線考試
試卷年份2008年下半年
試題題型【分析簡答題】
試題內(nèi)容

閱讀以下說明和Java代碼,將應填入 (n) 處的字句寫在答題紙的對應欄內(nèi)。
【說明】 
java.util庫中提供了Vector模板類,可作為動態(tài)數(shù)組使用,并可容納任意數(shù)據(jù)類型。
該類的部分方法說明如下表所示:
方法名         含義
add(k)          向 vector 對象的尾部添加一個元素 k
removeElementAt(i)   刪除序號為 i 的元素(vector 元素序號從 0 開始)
isEmpty()        判斷 vector 對象是否含有元素
size()          返回 vector 對象中所包含的元素個數(shù)
【Java 代碼】     
import   (1) ;
public class JavaMain {
 static private final int   (2)  = 6;
 public static void    main(String[] args){
     Vector<Integer> theVector = new Vector< (3) >();
   // 初始化theVector,將theVector的元素設置為0至5
   for (int cEachItem = 0; cEachItem < ARRAY_SIZE; cEachItem++)
   theVector.add( (4) );
 
   showVector(theVector);    // 依次輸出theVector中的元素
   theVector.removeElementAt(3);   
showVector(theVector);
 }
 public static void showVector(Vector<Integer> theVector){
   if (theVector.isEmpty())  {
 System.out.println("theVector is empty.");
    return;
   }
   for (int loop = 0; loop < theVector.size(); loop++) {
 System.out.print(theVector.get(loop));
 System.out.print(", ");
   }
   System.out.println();
 }
}
該程序運行后的輸出結(jié)果為: (5) 


相關試題

推薦文章
合作網(wǎng)站內(nèi)容