Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

can someone give me an example of boolean statement?

+6 votes
asked Feb 13, 2015 in (Winter 14) by Rafael Rodriguez (100 points)

1 Answer

+2 votes
a boolean is either true or false. They are useful for if statements and while loops. An example of using this effectively would be:

This code could be used if you wanted to write a program that does some sort of action only when an object is "hit". There are many ways where this kind of code could be used. Booleans are handy when you want code to only run on specific conditions. You create a boolean to be true on the condition you want to run the code and false on code you don't want to run.

boolean hit = true;

while (hit) {

enter code in here that you want to run while an object has been "hit" also have an update step that allows to change the boolean variable when the object is not hit.

}
answered Feb 13, 2015 by Nowlan Savage (100 points)
...