更新源代码并且添加不同的参数

This commit is contained in:
YuCheng Hu 2020-01-27 14:39:15 -05:00
parent 3f6fb4cbcb
commit d7a8a79897
1 changed files with 9 additions and 2 deletions

View File

@ -3,14 +3,19 @@ package com.ossez.lang.tutorial.usecases;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* variable arguments use case
*/
public class VarargsCase {
private static final Logger logger = LoggerFactory.getLogger(VarargsCase.class);
/**
* sumVarargs
*
* @param intArrays
* @return
*/
static int sumvarargs(int... intArrays) {
static int sumVarargs(int... intArrays) {
int sum, i;
sum = 0;
for (i = 0; i < intArrays.length; i++) {
@ -20,11 +25,13 @@ public class VarargsCase {
}
/**
* Main Function
*
* @param args
*/
public static void main(String args[]) {
int sum = 0;
sum = sumvarargs(new int[]{10, 12, 33});
sum = sumVarargs(new int[]{10, 12, 33, 7});
logger.debug("The Sum of the arrays: {}", sum);
}
}