You are viewing a single comment's thread. Return to all comments →
class Add { public void add(int... x) { //int r = 0; String seperator = ""; int count = 0; int result = 0; for(int a : x) { //System.out.println(count+a); count = count + a; //System.out.println(a); System.out.print(seperator +a); seperator = "+";
} result = count; System.out.print("="+result); System.out.println();
} }
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 { public void add(int... x) { //int r = 0; String seperator = ""; int count = 0; int result = 0; for(int a : x) { //System.out.println(count+a); count = count + a; //System.out.println(a); System.out.print(seperator +a); seperator = "+";
} }