Java boolean keyword example
- Details
- Written by Nam Ha Minh
- Last Updated on 18 August 2019   |   Print Email
The boolean keyword is used to declare a variable as a boolean type, which represents only either true or false. For example:
boolean isAlive;
The boolean keyword can be used to declared return type of a method as well:
public boolean hasChildren() { return true; }
See all keywords in Java.
Related Topics:
Other Recommended Tutorials:
- 9 Rules about Constructors in Java
- 12 Rules and Examples About Inheritance in Java
- 12 Rules of Overriding in Java You Should Know
- 10 Java Core Best Practices Every Java Programmer Should Know
- Understand Interfaces in Java
- Understand how variables are passed in Java
- Understand encapsulation in Java
Comments
Thank you so much for providing clear Java illustrations and examples throughout your website. For example, your keyword list is the perfect reference tool as I continue through my Java Masterclass.