+ 5

Java what is while(!(statement))

So im learning Jeroo which is based on java and i need to know what while(!(statement)) is and what it does:D thanks in advance

16th Nov 2018, 5:09 PM
Emperor Bob
Emperor Bob - avatar
5 Answers
+ 7
It repeats some code while a condition is false. So your example code repeats while !(LEFT && RIGHT). Take a look at this diagram: https://code.sololearn.com/WdB8HSffTk3o/?ref=app
16th Nov 2018, 9:30 PM
Rowsej
Rowsej - avatar
+ 5
while(!(bob.isFlower(LEFT) && bob.isFlower(RIGHT))) Example code
16th Nov 2018, 5:17 PM
Emperor Bob
Emperor Bob - avatar
+ 4
Vedant Bang you see i did something so there were 2statements and put individual !'s in front of them but the output was different
16th Nov 2018, 8:03 PM
Emperor Bob
Emperor Bob - avatar
+ 2
Emperor Bob evaluate the two conditions separately first. Their result will be a true or a false. Now, they have been joined by && Hence true && true = true true && false = false false && false = false
17th Nov 2018, 4:10 AM
Vedant Bang
Vedant Bang - avatar
+ 1
While (condition is true) {run code} ! is negation operation so while (!(condition is false)) {run code}
16th Nov 2018, 5:27 PM
Vedant Bang
Vedant Bang - avatar