From a08795f64cb03d16a26c3fab1c87667600e0a371 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Mon, 27 Jan 2020 12:22:45 -0500 Subject: [PATCH] use case for VarargsCase --- .../lang/tutorial/usecases/VarargsCase.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/com/ossez/lang/tutorial/usecases/VarargsCase.java diff --git a/src/main/java/com/ossez/lang/tutorial/usecases/VarargsCase.java b/src/main/java/com/ossez/lang/tutorial/usecases/VarargsCase.java new file mode 100644 index 0000000000..e11ec63926 --- /dev/null +++ b/src/main/java/com/ossez/lang/tutorial/usecases/VarargsCase.java @@ -0,0 +1,30 @@ +package com.ossez.lang.tutorial.usecases; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VarargsCase { + private static final Logger logger = LoggerFactory.getLogger(VarargsCase.class); + + /** + * @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); + } + + /** + * @param args + */ + public static void main(String args[]) { + int sum = 0; + sum = sumvarargs(new int[]{10, 12, 33}); + logger.debug("The Sum of the arrays: {}", sum); + } +}