Java PrintStream.print(boolean b)

Syntax

PrintStream.print(boolean b) has the following syntax.

public void print(boolean b)

Example

In the following code shows how to use PrintStream.print(boolean b) method.


import java.io.*;
//from  w  ww  . jav a  2 s  . co  m
public class Main {

   public static void main(String[] args) {
      boolean bool = false;


      
      PrintStream ps = new PrintStream(System.out);

      // print boolean
      ps.print(true);
      ps.print(bool);

      // flush the stream
      ps.flush();

   }
}

The code above generates the following result.