There are two problems in your code:
The
+
operator is allowed for primitive numeric types only. In this line of code:Sum.sum(new double[] {0,1,2} + {2,2,3});
You're trying to apply
+
operator fordouble[]
variables, which is not allowed, thus getting the exception. Since the method already accepts 2 argumentsdouble[]
, then send bothdouble[]
s by separating them using comma,
.:Sum.sum(new double[] {0,1,2}, new double[] {2,2,3});
This line of code:
int[] s = new double[a.length];
You cannot initialize an array of primitive type with an array of another primitive type.
int[]
anddouble[]
are complete different classes. So, instead change the type declaration for your variable:double[] s = new double[a.length];
More info: