You are viewing a single comment's thread. Return to all comments →
class Add { void add(int a, int b, int... other) { String sumStr = String.format("%d+%d", a, b); int sum = a+b; for (int i=0; i<other.length; i++) { sumStr += String.format("+%d", other[i]); sum += other[i]; } System.out.println(sumStr + "=" + 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 →