Java IO Tutorial - Java PrintWriter.print(int i)








Syntax

PrintWriter.print(int i) has the following syntax.

public void print(int i)

Example

In the following code shows how to use PrintWriter.print(int i) method.

import java.io.*;
//w  w  w  .j a  v  a 2 s.c o  m
public class Main {

   public static void main(String[] args) {
      int i = 1234;

      
      PrintWriter pw = new PrintWriter(System.out);

      // print int
      pw.print(i);

      // change the line
      pw.println();

      // print another int
      pw.print(567);

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.