import java.io.*;

// This program demonstrates boolean variables

public class Booleans {

    public static void main (String [] args) {
	boolean b1 = 2 < 3;
	boolean b2 = !b1;
	b1 = b1 && b2;

	System.out.println("b1 = " + b1 + " b2 = " + b2);

	// conditionals with boolean variables:
	if (b1) {
	    System.out.println("Red");
	} else {
	    System.out.println("Blue");
	}
    }
}

This is an example from CSci 1211 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.