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








Syntax

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

public void print(int i)

Example

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

/*  ww  w. j  a  v a 2  s . c  om*/
import java.io.*;

public class Main {

   public static void main(String[] args) {
      int x = 123;

      
      PrintStream ps = new PrintStream(System.out);

      // print integer
      ps.print(x);
      ps.print(100);

      // flush the stream
      ps.flush();

   }
}

The code above generates the following result.