这不是java的bug,楼主基本功太差了吧

解决方案 »

  1.   

    因为Vector中存放的是相当于元素的引用或者说指针。   v.add(0,s);后对S做了修改,然后   v.add(1,s); 因此Vector存放的两个元素实际上都是修改后的S
      

  2.   

    楼主基本类型和引用类型还没分清楚就搞Vector啦, 一步一步来吧. 不要急于求成, 从HelloWorld学起!
      

  3.   

    可是 执行v.add(0,s);的时候s中存放的是{"a","1"}啊,难道程序不是顺序执行的?
      

  4.   

    明白了!谢谢大家,尤其是:lxpbuaa(桂枝香在故国晚秋)
      

  5.   

    晕,这也叫BUG,不过thinking in java中的讲的一个不知道是不是import java.io.*;
    import java.util.*;
    public class IOProblem{

          public static void main(String[] args) 
      throws IOException {
        DataOutputStream out =
          new DataOutputStream(
            new BufferedOutputStream(
              new FileOutputStream("Data.txt")));
        out.writeDouble(3.14159);
        out.writeBytes("That was the value of pi\n");    
        out.writeDouble(3.14159);
        out.close();    DataInputStream in =
          new DataInputStream(
            new BufferedInputStream(
              new FileInputStream("Data.txt")));
        BufferedReader inbr =
          new BufferedReader(
            new InputStreamReader(in));
        // The doubles written BEFORE the line of text
        // read back correctly:
        System.out.println(in.readDouble());
        // Read the lines of text:
        System.out.println(inbr.readLine());
        
        // Trying to read the doubles after the line    
        // produces an end-of-file exception:
        //这句出现Exception
        System.out.println(in.readDouble());
        }
    }