0
How to create a method takes any number of parameters you give to it ?
it's easy if you want to create a method for example sum the numbers you gave it of integers just type like that int addMethod(int...a){ int sum=0; for(int i : a) sum += i; return sum; } i hope you understand :)
2 Réponses
0
public int sum(int... s)
{
int sum=0;
for(int i:s){
sum=i+sum;
}
return sum;
}
0
right 👍