import java.io.*; import java.util.*; // This class will take in the file lyrics.txt and print them out // in reverse order public class Recursion { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("lyrics.txt")); reverseFile(input); } // Given a Scanner input that is hooked up to a file we will // print out the lines in reverse order public static void reverseFile(Scanner input) { if(input.hasNextLine()) { // recursive case String line = input.nextLine(); reverseFile(input); System.out.println(line); // - do our part of the problem // - solve a smaller problem by recurring } // base case // if the Scanner doesn't have another line, do nothing! } }