I am having a hard time understanding what this ! in this while loop does. I know it inverts the boolean value, but how does that cause the loop to exit? If it is false then it truns it to true, and if it is true then it turns it to false?
String userChoice;
do
{
userChoice = select.promptChoice();
} while ( !select.isValidChoice(action ) );
In English:
While
select.isValueChoice(action)returnsfalse(!true) douserChoice = select.promptChoice();The reason for the
!is so that loop exits whenisValidChoicereturnstrue.