Do something like:
//...
int lastNum = duplicate.remove(duplicate.size()-1);
return lastNum + calculateSumArrayListHelper(duplicate);
Krokcy
Junior Poster in Training
55 posts since Sep 2010
Reputation Points: 24
Solved Threads: 6
Skill Endorsements: 0
Question Answered as of 10 Months Ago by
Krokcy
and
naief i don't think your clone method works, might wanna check that
Can you clarify that? ArrayList certainly implements a shallow clone(), so what do you suspect, and why?
Thanks.
JamesCherrill
... trying to help
8,504 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29
Yes, clone is defined as returning an Object, so you are stuck with the cast. What version of Java are you using? Eclipse 4.2/Java 1.7 doesn't complain about it.
JamesCherrill
... trying to help
8,504 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29