Saturday 21 June 2014

Program to show boolean data type

package sum;

public class bool {

public static void main(String[] args) {
// Demonstrate boolean values.
boolean b;
b = false;
System.out.println("b is " + b);
b = true;
System.out.println("b is " + b);
// a boolean value can control the if statement
if(b) System.out.println("This is executed.");
b = false;
if(b) System.out.println("This is not executed.");
// outcome of a relational operator is a boolean value
System.out.println("10 <9 is " + (10 < 9));

}

}

output:
b is false
b is true
This is executed.
10 <9 is false

No comments:

Post a Comment

SAY HELLO!!