You are viewing a single comment's thread. Return to all comments →
class Add{ public static void add(int... numbers){ StringBuilder sb = new StringBuilder(); int suma = 0; for (int i = 0; i < numbers.length; i++) { suma += numbers[i]; sb.append(numbers[i]); if(i < numbers.length-1){ sb.append("+"); } } sb.append("="+suma); System.out.println(sb); } }
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 →