Count the number of times that a user inputs a string.
String s; // current string in input
int counter;
counter = 0;
s = JOptionPane.showInputDialog("Input a string");
while (s != null) {
counter++;
s = JOptionPane.showInputDialog("Input a string");
}
System.out.println("Number of strings in input = " + counter);