class RecTest
{
int values[];
RecTest(int i)
{
values=new int[i];
}
void pray(int i)
{
if (i==0) return;
else
{
System.out.println(+values[i-1]);
pray(i-1);
}
}
}
class aka
{
public static void main(String h[])
{
RecTest ob=new RecTest(10);
int i;
for(i=0;i<10;i++)
ob.values[i]=i;
ob.pray(10);
}
}
This program works fine, it prints 9,8,7,6,5,4,3,2,1,0 in descending order. But when i interchange the System.out.println(+values[i-1]) and the pray(i-1) statements, it prints 0 to 9 in ascending order.
Can someone explain me why is that happening?
I just cant make sense out of it . Source-Java-2, A complete reference,5th Edition,page 171