Java IO Tutorial - 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.*;
//  w  w  w .j  a va2s  . c  o  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.