using java Recursion Create a Class to practice with Recursi
using java
(Recursion) Create a Class to practice with Recursion. Call your class “Recur”, and store it in a file called “Recur.java”. In this class include just one method call it methRecur(). Have main start things out by instantiating the class and calling the methRecur() method. In the methRecur() method, first print out “Entering Method”. Then call the methRecur() method again. After calling the method print “Leaving Method”. Make it so that the method will only recurse 100 times. Use an if statement for this.
Solution
public class Recur {
static int count=0;
static void methRecur()
{
if(count==10)
System.exit(0);
else count++;
System.out.println(\"Entering method\");
methRecur();
System.out.println(\"Leaving method\");
}
public static void main(String[] args) {
methRecur();
}
}
