This is the code I have right now and can't figure out why this while loop isnt ending when there is a period entered.
while (emailTxt!="."){
emailTxt = "";
emailTxt = scanner.nextLine();
totalText.add(emailTxt);
}
This is the code I have right now and can't figure out why this while loop isnt ending when there is a period entered.
while (emailTxt!="."){
emailTxt = "";
emailTxt = scanner.nextLine();
totalText.add(emailTxt);
}
emailTxt is a String. A String in Java is considered an Object. You want to use the Object.equals().
So
while(!(emailTxt.equals("."))
You should use equals()
to compare two string.
while (!".".equals(emailTxt)) {
// ...
}