You are viewing a single comment's thread. Return to all comments →
class Add { void add(int... number) {
int counter = 0; int sumNum = 0; for (int i = 0; i < number.length; i++) { sumNum = sumNum + number[i]; counter++; if(counter<number.length){ System.out.printf("%d+", number[i]); }else{ System.out.printf("%d", number[i]); } } System.out.printf("=%d%n", sumNum); }
}
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 →
class Add { void add(int... number) {
}