How to solve this recursive function puzzle?
<p>During interview in a company, interviewer ask me this question.</p>

<p>Suppose we have a array like this:</p>

<pre><code>int[] arr = {2,12,14,-16,18,22,45};
</code></pre>

<p>They told me to code a function for get sum of array. </p>

<p>So how can I get sum of this array, by using function, with below given conditions:</p>

<p>Condition 1: I can't use any global variable. Means array is also define inside function.
<BR><BR>Condition 2: And I must use recursive function.</p>

<p>Coding should be in java.</p>

<p><BR>I did not post code here because this question was ask to me during interview and I was not able to found solution for this problem. I found some solutions on stackoverflow but in those solutions no one define array inside the function.</p>