You are viewing a single comment's thread. Return to all comments →
public void add(Integer... numbers) { int total = Arrays.asList(numbers) .stream() .mapToInt(Integer::intValue) .sum(); String output = Arrays.asList(numbers) .stream() .map(n -> n.toString()) .collect(Collectors.joining("+")); System.out.println(output + "=" + total); }
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 →