import java.util.*; // Client program to introduce examples of recursive code public class RecursionExamples { public static void main(String[] args) { writeStars(3); } // post: print the lines from the Scanner in reverse order public static void reverseLines(Scanner input) { if (input.hasNextLine()) { // recursive case String line = input.nextLine(); reverseLines(input); System.out.println(line); } // base case - do nothing } // pre: n >= 0 // post: print out a row of n stars public static void writeStars(int n) { if (n == 0) { // base case System.out.println(); } else { // recursive case, n > 0 System.out.print("*"); writeStars(n-1); } } }