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 trialAleksandar Ivkovic
510 PointsBoolean
Can someone please explain me what is boolean and how do we use it?
2 Answers
Mikkel Rasmussen
31,772 PointsA boolean is either true or false.
So we can say if a person is running and the person has a variable called running that means the running variable would be true because we know the person is running but then the person stops running - the running variable will be false.
Belve Marks
7,332 PointsA Boolean is a data type with only two possible values: on/off, true/false. We use it because they are handy in decision-making logic, and they mirror the physical constrains of computer hardware (think bits). There are many great resources on the web for reading more. Try the wiki article on Boolean data types.
Specifically for Java and most programming languages, they are used in if...then statements. The conditionals will always return a Boolean value: true lets the code within the if statement run, while false will skip that part of the conditional and move through the rest of the code.