标签:形参 data- array usecase cell extern 程序 ide block
请参考 GitHub 上的源码代码:
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) { int sum, i; sum = 0; for (i = 0; i < intArrays.length; i++) { sum += intArrays[i]; } return (sum); } /** * Main Function * * @param args */ public static void main(String args[]) { int sum = 0; sum = sumVarargs(new int[]{10, 12, 33, 7}); logger.debug("The Sum of the arrays: {}", sum); } }
程序运行的输出结果为:
2020/01/27 14:33:52 DEBUG [com.ossez.lang.tutorial.usecases.VarargsCase] - The Sum of the arrays: 62
标签:形参 data- array usecase cell extern 程序 ide block
原文地址:https://www.cnblogs.com/huyuchengus/p/12237361.html