When i trying write in method variable length parameters(int ...x), i have this problem :
"Operator '+' cannot be applied to 'int[]','int'"
i want to understand, can i use (int ...x) when i use lambdas, and if can, how?
class calculations {
public static void main(String[] args) {
func obj = (x) -> x+1;
int result = obj.sum(10);
System.out.println(result);
}
}
interface func {
int sum(int ...x);
}
I know that variable length parameters(int ...x) indicates that it will be optional and will represent an array, based on this i can add multiple parametrs, for example func obj = (x,y,w) -> x+y+w; but it's dont work.