1
为什么这样没有工作Java - 如何将数组的每个元素复制到ArrayList?
import java.util.ArrayList;
public class Vector
{
ArrayList<Long> vector;
public Vector(long ...vector)
{
for (long value : vector)
this.vector.add(new Long(value));
}
}
当我提出一个新的客体像Vector a = new Vector(4,7,8);
它说
java.lang.NullPointerException
我试过Arrays.asList(array);
和
for (int i=0;i<vector.lenght;i++)
this.vector.add(vector[i])
和同样的错误
谢谢我已经准备好了 – user3763927