a. public static void main(String[] args) { xmethod(5); } public static void xmethod(int n) { if(n > 0) { System.out.print( n + " "); xmethod (n-1); } } } //output: 5 4 3 2 1 b. public static void main(String[] args) { xmethod(5); } public static void xmethod(int n) { if(n > 0) { xmethod (n-1); System.out.print( n + " "); } } } //Output: 5 4 3 2 1
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter