Advertisement
DulcetAirman

Recursive method for sum

May 9th, 2015
335
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   public static int sum(final List<Integer> list) {
  2.     if (list.isEmpty())
  3.       return 0;
  4.     return list.get(0) + sum(list.subList(1, list.size()));
  5.   }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement