Question: In this java code when i = 1, public static void rec1(int i) { if(i == 0) { System.out.print(i + ); for(int j =

In this java code when i = 1,

public static void rec1(int i) {

if(i == 0) {

System.out.print(i + " ");

for(int j = 0; j < 2; j++) {

rec1(i - 1);

rec1(i - 1);

}

}

How does the for loop keep the program running, printing 0 0 0 0 0 0 0 ...., causing a stack overflow?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!