public class Main {
public static void main(String[] args) {
double sum = getSum(10.0,20.00,30.00);
System.out.println(sum);
sum = getSum(1,2,2,3,4,5,6,8);
System.out.println(sum);
}
static double getSum(double ... arr)
{
double sum=0.0;
for(double ele:arr)
{
sum+=ele;
}
return sum;
}
}
java方法的可变参数
最新推荐文章于 2022-12-06 10:05:34 发布