Advertisement
joseleonweb

Untitled

Feb 1st, 2021
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. public class RecursionExample {
  2.  
  3.     public static void main(String[] args) {
  4.         recurseMethod(4);
  5.     }//end method main
  6.    
  7.     static void recurseMethod(int num){
  8.         if(num == 0)
  9.             return;
  10.         else{
  11.             System.out.println("hello " + num);
  12.             recurseMethod(--num);
  13.             System.out.println(""+num);
  14.             return;
  15.         }//endif
  16.     }//end method recurseMethod
  17. }//end class RecursionExample
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement