Java Data Type Tutorial - Java System in








Syntax

System.in has the following syntax.

public static final InputStream in

Example

In the following code shows how to use System.in field.

//w w  w  .j  av a 2 s.c  om
import java.io.IOException;

public class Main {

  public static void main(String[] arg) {
    System.out.println("Type something");
    try {
      System.in.read();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

}

The code above generates the following result.