java Vector

public static void main(String[] args){
        Vector v = new Vector();
        //
        v.addElement(111);
        v.addElement(222);
        v.addElement(333);
        v.addElement("aaa");
        v.addElement("bbb");
        v.addElement("ccc");
        
        v.add(0, "zero");
        System.out.println(v);

        //
        v.remove(Integer.valueOf(111));
        System.out.println(v);
        v.remove(1);
        System.out.println(v);

        //
        v.set(0, "零");
        System.out.println(v);

        //
        System.out.println(v.get(0));

        // 遍历
        for(int i = 0; i < v.size(); i++){
            System.out.println(v.get(i));
        }
        System.out.println("------------");
        for(Object o : v){
            System.out.println(o);
        }
        
    }

 

posted @ 2023-02-25 15:54  我歌且谣  阅读(37)  评论(0编辑  收藏  举报