Search code examples
javaoperand

Bad operand types


 public double getRandKg(double[] value)
{
    double min = 0.0;
    double max = 0.0;

    value * 0.90 = min;          <------ this is where it says bad operand
    value * 1.10 = max;                   types for binary operator '*'
    Random r = new Random();              first type double[] second type double

    double randomValue = min + (((max-min)+1) * r.nextDouble());
    return randomValue;                                                                         //

}

It's late and maybe I just can't think straight. It's just saying I can't multiply a double[] by a double?


Solution

  • double[] is an array. How can you multiply an array of double values with a single double value?

    use double[someIndex] * doubleVar to multiply with a single value, and put the expression on the right side, not the left.