I'm a beginner in Java and I'm entering a contest, the demo contest end in a few minutes but I will just ask for my own sanity. It's meant to take inputs until a double space is inputted, and print mirror pair for pq & bd and ordinary pair for anything else. The issue is that my output has two random empty line of code at the end that I cannot figure out how to get rid of, and that fails me on the tests.
`import java.io.;
import java.util.;
public class Main {
static ArrayList<String> TF = new ArrayList<String>();
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String input = "";
do {
input = keyboard.nextLine();
if(input != " ") {
if(input.equals("bd") || input.equals("db") ||input.equals("pq") ||input.equals("qp")) {
TF.add("Mirrored pair");
} else if (input.equals(" ")) {
continue;
}else{
TF.add("Ordinary pair");
}
}
} while(input.equals(" ")==false && input.isEmpty() == false);
System.out.println("Ready.");
for(int i =0; i<TF.size(); i++) {
if(TF.get(i).equals("Mirrored pair") || TF.get(i).equals("Ordinary pair")) {
System.out.println(TF.get(i));
} else {
System.exit(0);
}
}
}
}`