程序是在jdk1.6环境中编写的,因为jdk1.3中没有split()方法,没有Vector<Double>这种泛型的定义,而EAI方法使用的JDK限制在1.4版本以下,所以想要把jdk换成1.3的,但是对于1.3中相当于split()方法的函数以及泛型的一些东西不是很了解,现把一部分程序贴至如下:    Vector<Double> XAxis1=new Vector<Double>();
Vector<Double> YAxis1=new Vector<Double>();
Vector<Double> ZAxis1=new Vector<Double>();
Vector<Double> XAxis=new Vector<Double>();
Vector<Double> YAxis=new Vector<Double>();
Vector<Double> ZAxis=new Vector<Double>();
//变量定义 try{
BufferedReader reader=new BufferedReader(new FileReader(path));
String content=null;
while((content=reader.readLine())!=null){
textarea1.append(content+"\n");
String[] st =content.split(",");
    XAxis1.addElement(Double.valueOf(st[0]).doubleValue());
    YAxis1.addElement(Double.valueOf(st[1]).doubleValue());
    ZAxis1.addElement(Double.valueOf(st[2]).doubleValue());
}
reader.close();
}catch(IOException ie){
textarea1.append("read from file:"+ie.getMessage());
}
catch(SecurityException se){
textarea1.append("Security constraint,Can't read from the file!\n");
}
}

for(int i=0;i<=w-1;i++){
XAxis.addElement((XAxis1.elementAt(i)+XAxis1.elementAt(i+w))/2);
YAxis.addElement((YAxis1.elementAt(i)+YAxis1.elementAt(i+w))/2);
ZAxis.addElement(((ZAxis1.elementAt(i)+ZAxis1.elementAt(i+w))/2-(ZAxis1.elementAt(0)+ZAxis1.elementAt(0+w))/2)*1000);
}JDK1.3中Vector变量不能向上面一样定义,而且(XAxis1.elementAt(i)+XAxis1.elementAt(i+w))/2不能这样写,说是object对象类型不能直接关系运算,要转类型,这个不会,麻烦哪位高人帮忙把上面程序用在1.3环境下改下!

解决方案 »

  1.   

    我很疑惑··为什么要追求过时的JDK··
      

  2.   

    不是上面说了嘛,1.6中EAI方法不行,实现EAI的条件是JDK版本限制在1.4以下
      

  3.   

    泛型是JDK新版本中的加入的老版本就不支持你还是去看下先JDK的特性在说吧!
      

  4.   

    String#split 是采用正则表达式处理的,而正则表达式是在 JDK 1.4 中加入的,JDK 1.3 中是没有的。用 JDK 1.3 的话,可以使用 Apache Jakarta Regexp 或者 Apache Jakarta ORO 库。http://jakarta.apache.org/regexp/index.html
    http://jakarta.apache.org/oro/index.html
      

  5.   

    泛型的话,在 JDK 1.3 环境中需要全部去掉,在使用时需要采用类型强制转换就可以了。
      

  6.   

    向下兼容的代码修改很麻烦,除了语法本身之外,还涉及类库的 API
      

  7.   

    1.3中就使用StringTokenizer替代split吧
      

  8.   

    JDK 1.3 中除了没有泛型、正则表达式之外,还没有 JDK 5 中的自动装箱和拆箱功能XAxis1.addElement(Double.valueOf(st[0]).doubleValue());
    XAxis1.addElement(Double.valueOf(st[0]));XAxis.addElement((XAxis1.elementAt(i)+XAxis1.elementAt(i+w))/2);
    XAxis.addElement(toWrapDouble(getDouble(XAxis1, 1) + getDouble(XAxis1, i+w) / 2));private static double getDouble(Vector vector, int index) {
        return toDouble(vector.elementAt(index));
    }private static Double toWrapDouble(double num) {
        return Double.valueOf(num);
    }private static double toDouble(Object obj) {
        if(obj == null) {
            throw new NullPointerException("obj is null!");
        }
        if(!(obj instanceof Double)) {
            throws new ClassCastException("obj must be Double!");
        }
        return ((Double)obj).doubleValue();
    }
      

  9.   

    在项目的最开始,就要考虑jdk的版本吧,不同的版本,实现方法不同,别等代码都写的差不多了,才发现jdk版本有问题,..............
      

  10.   

    谢谢火龙果这个再改下就可以了,学到了不少,再次拜谢!
    private static Double toWrapDouble(double num) {
        return Double.valueOf(String.valueOf(num));
    }
      

  11.   

    除了不支持泛型,jdk 1.3还有哪些大的bug啊