You are viewing a single comment's thread. Return to all comments →
class Add { public void add(int... n) { int sum = 0; List<String> arr = new ArrayList<>(); for (int num : n) { sum += num; arr.add(Integer.toString(num)); } System.out.println(String.join("+", arr) + "=" + sum); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Varargs - Simple Addition
You are viewing a single comment's thread. Return to all comments →