Java IO Tutorial - Java PrintWriter.println(boolean x)








Syntax

PrintWriter.println(boolean x) has the following syntax.

public void println(boolean x)

Example

In the following code shows how to use PrintWriter.println(boolean x) method.

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

   public static void main(String[] args) {
      boolean bool = false;
      try {
         
         PrintWriter pw = new PrintWriter(System.out);

         // print boolean
         pw.println(bool);
         pw.println(true);

         // flush the writer
         pw.flush();

      } catch (Exception ex) {
         ex.printStackTrace();
      }
   }
}

The code above generates the following result.