/** * Recursively print the contents of an array * * @author ggtowell * Created: Oct 27, 2023 */ public class PrintArray { public static void main(String[] args) { printArray(args); } /** * Print the contents of the array. * This actually just calls a helper with an extra parameter */ public static void printArray(String[] arr) { printArrayHelper(arr, 0); } /** * Actually print the contents of an array * @param arr the array to be printed * @param loc the current location in the array */ private static void printArrayHelper(String[] arr, int loc) { if (loc >= arr.length) { return; } System.out.println(loc + ": " + arr[loc]); printArrayHelper(arr, loc + 1); } }