Write a recursive algorithm which takes an int n and prints a row of asterisks of length n.
Here we can return the String or just print either works.
Write a recursive algorithm that takes a string s and writes the characters vertically
Recursion must have 1., a stopping case and 2., a recursive method where the method is calling itself.
In this case, we can return the String or print it. Both work.
When might you get a java.lang.StackOverflowError
When the method has been called so many times that it has ran out of space in memory.
This would happen when there is no stopping case.
How do you write lines from a file in reverse order?
public class ReverseFile extends ConsoleProgram {
public void run() {
println("This program reverses the lines in a file.");
BufferedReader rd = openFileReader("Enter input file: ");
String[] lines = readLineArray(rd);
for (int i = lines.length - 1; i >= 0; i--) {
println(lines[i]);
}