package calculator;import java.util.*;public class Test {
  Vector vector1 = new Vector();
  public Test() {
    String[] a = {
        "1", "2", "3", "4", "5"};
    for (int i = 0; i < 5; i++) {
      vector1.addElement(a[i]);
    }
  }  public String[] read() {
    String[] b =new String[5];
    try {
      for (int i = 0; i < 5; i++) {
        b[i] = (String) vector1.get(i);
      }
    }
    catch (NullPointerException e) {
      e.printStackTrace();
    }
    return b;
  }  public static void main(String arg[]) {
    try {
      Test test = new Test();
      String[] c = test.read();
      for (int i = 0; i < 5; i++) {
        System.out.println(c[i]);
      }
    }
    catch (NullPointerException e) {
      e.printStackTrace();
    }
  }
}

解决方案 »

  1.   

    没很仔细的看,但你的main函数都写错了public static void main(String[] args)
      

  2.   

    不确定数组可以这样,下面的代码我是随便写的,没调试过,可能编不过,你自己试试啦
    List temp = new ArrayList();
    try{
    for(int i=0;i<vecotor1.size();i++){
    temp.add(vector1.get(i));
    }
    }
    catch(NullPointerException e){
    e.printStackTrace();
    }
    return (String[]) temp.toArray(new String[0]);
      

  3.   

    public static void main(String[] args)
    args可以随便吧。
    String[] b =new String[5];
    for (int i = 0; i < 5; i++)
    i<5和new String[5]他俩是统一的。如过i<a,你就new String[a]就行啊。        
      

  4.   

    public static void main(String[] args)
      

  5.   

    Vector本来就是不确定数组大小时使用的,干吗还转成ArrayList呢?ArrayList是比Vector开销小一些,那干脆一开始就用ArrayList呀。Vector也有toArray()的