Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects Delivering the MVP Validating and Normalizing User Input

Arcee Palabrica
Arcee Palabrica
8,100 Points

Clarification about while (! isAcceptable);

So we set isAcceptable = false does that mean (! isAcceptable) = true ?

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Correct! If isAcceptable is false then (! isAcceptable) is true.

Arcee Palabrica
Arcee Palabrica
8,100 Points

Thanks Chris. So in the do-while loop does it mean that as long as isAcceptable is false it will keep on looping until it flips to true? Right?

Mladen Jovanovic
Mladen Jovanovic
4,662 Points

I was looking for this very question.

I think I got it, but just to check:

The idea of a do-while loop is that it executes the code in the "do" block until the expression in "while()" evaluates to "false" (essentially: keep doing this as long as the condition is true), right?

So, in our case, we have the "isAcceptable" boolean set to "false" and the statement in "while" is going to be true as long as "isAcceptable" stays false, right?

Meaning that the only way to stop the loop is for a letter to pass the validation and normalization, which would change "isAcceptable" to true, which would make the expression in "while()" false?

Sorry if this is redundant, but this actually broke my brain for a while, especially since I wasn't entirely sure how do-while worked. :)