You have to switch the if/else
statement with while
.
Sample :
inputValues = userInput.readLine();
while (!".".equals(inputValues) {
//do your stuff
//..and after done, read the next line of the user input.
inputValues = userInput.readLine();
}
Note: Never compare the values of String
objects with the ==
operator. Use the equals()
method.
If you just want to test, whether the sentence the user inputs contains a .
symbols, you just have to switch from equals()
to contains()
. It's a built-in method from the java.lang.String
class.
Sample:
while (inputValues != null && !inputValues.contains(".")) {
//do your stuff
}