no title...

Page 48

Boolean Type The boolean type supports a program when the program involves logic. Thus, the boolean data type returns a value after evaluating a logical/conditional statement. Conditional statements require an answer (true or false) regarding a specific statement. A conditional statement consists of variables and/or expressions. The following is a boolean data type example:

public class VariableExample { public static void main(String[] args) { boolean result; result = false; System.out.println("Boolean variable 'result' was initialized to " + result); System.out.println("Is this a true or false statement '100 greater than 99'? " + (100>99)); } }

Figure 2.16 – Data Type boolean


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.