void printArray(int i)
{
if(i==0) return;
else printArray(i-1);
System.out.println("["+(i-1+"]"+values[i-1]));
}
explain above code for i=1
void printArray(int i)
{
if(i==0) return;
else printArray(i-1);
System.out.println("["+(i-1+"]"+values[i-1]));
}
explain above code for i=1
it will print you 0.
so you call your function like this:
printArray(1);
-it will go and check if 1==0 witch it’s false and it will call herself again but with i value lower by 1 unit: printArray(0).Now when the function check the condition it will return to the previous point and it will print 0 because you print the value at the index decreased by 1;
Sorry for bad english.