public Integer test3(Integer ...args) {
List<Integer> costBeforeTax = Arrays.asList(args);
int sum = costBeforeTax.stream().reduce((a,b)->a+b).get() ;
return sum;
}
public static void main(String[] args) {
MavenTest t = new MavenTest();
System.out.println( t.test3(1,2,3,4,5) );
}
java8-汇总数组总的值及可变参数
最新推荐文章于 2023-07-18 11:41:42 发布