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.
Frage
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
?
Lösung
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.
Andere Tipps
I believe you are trying to set the values for min and max. In which case you are doing the wrong way round.
It should be:
min = value * 0.90;
max = value * 1.10;
http://docs.oracle.com/javase/tutorial/reflect/member/fieldValues.html
--
Also you cannot multiply an array by a double. You should refer to which key=>value in the array you want to use.
For example
min = value[0] * 0.90;
min = value[0] * 0.90;
Where value[0] refers to the first array index (as arrays start from 0)
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html