Skip to content

Commit d4b4b7c

Browse files
authored
Create RecursionEx.java
1 parent fde63ed commit d4b4b7c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

algorithms/RecursionEx.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.zetcode;
2+
3+
public class RecursionEx {
4+
5+
public static void main(String[] args) {
6+
7+
printWord("rock", 10);
8+
}
9+
10+
public static void printWord(String word, int count) {
11+
12+
System.out.printf("%d %s%n", count, word);
13+
14+
if (count > 1) {
15+
16+
printWord(word, count - 1);
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)