添加两个向量给我NullPointerException

时间:2016-02-15 03:06:00

标签: java vector

public double[] add (double[] u, double[] v) 
{
    double[] output = new double[u.length];

    for(int i = 0; i < u.length; i++)
    {
        output[i] = u[i] + v[i];
    }
    return output;
}
public double dotProduct(double[] u, double[] v) 
{
    double output = 0.0;

    for(int i = 0; i < u.length; i++)
    {
        output += u[i] * v[i];
    }

    return output;
}
public double[] scalarProduct (double alpha, double[] v) 
{
    double[] output = new double[v.length];

    for(int i = 0; i < v.length; i++)
    {
        output[i] = v[i] * alpha;
    }

    return output;
}
public double norm (double[] v) 
{
    return 0;
}

嗨,我正在尝试添加两个向量,但是当我运行它时,它会给我这个错误:

你能识别它为什么打印NullPointException错误吗?

在add方法中,double [] output = new double [u.length];有NullPointerException。

0 个答案:

没有答案