Java boolean KeywordIn Java, the boolean keyword is a primitive data type. It is used to store only two possible values, either true or false. It specifies 1-bit of information and its "size" can't be defined precisely. The boolean keyword is used with variables and methods. Its default value is false. It is generally associated with conditional statements. Examples of Java boolean keywordExample 1: Simple boolean exampleTest it NowOutput: true Example 2: Comparing the variables of boolean typeTest it NowOutput: true false false Example 3: Method of boolean typeTest it NowOutput: true Example 4: Comparing objectsTest it NowOutput: Is objects are equal : false Example 5: Finding a prime numberTest it NowOutput: prime
Next TopicJava Byte Keyword
|