I'm trying to get the method printMethod to execute 6 times for 6 different inputs, but it takes one input, outputs the result once and then ends. I have tried positioning the method calls in different locations but it doesn't seem to make any difference. Could someone advise me on what I'm doing wrong?
import java.util.Scanner;
public class Lab_Week4_PrintTable_Part2 {
public static void main(String[] args) {
printMethod();
printMethod();
printMethod();
printMethod();
printMethod();
printMethod();
}
private static void printMethod() {
Scanner data = new Scanner (System.in);
String output = data.nextLine();
System.out.println("---------------------");
System.out.println("| | | | | |");
System.out.println(output);
System.out.println("| | | | | |");
System.out.println("---------------------");
data.close();
}
}