You are viewing a single comment's thread. Return to all comments →
class Add{ int add(int... numbers){ int a = 0; StringBuilder sb = new StringBuilder();
for(int num: numbers){ a+= num; sb.append(num + "+"); } System.out.print(sb.deleteCharAt(sb.length()-1)); System.out.println("=" + a); return a; }
}
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{ int add(int... numbers){ int a = 0; StringBuilder sb = new StringBuilder();
}