Input and output of the java

Export

In java output is:

 System.out.println ( "here outputting content");

Println output program after a blank line, and print the output lines is not empty.

The output can be formatted on the symbol corresponding processing as follows:

%d Formatted output integer
%x Formatted output hexadecimal integer
%f Formatted output float
%e Floating point numbers formatted output scientific notation
%s Format string

Use e.g.

  System.out.printf ( "%. 2F \ n-.", D); // show two decimal places

Entry

Input than output in java relatively complex:

In the following program as an example:

Import java.util.Scanner;
 public  class the Main {
     public  static  void main (String [] args) { 
        Scanner Scanner = new new Scanner (the System.in); // Create Object Scanner 
        System.out.print ( "Input test"); // Print message 
        string iNPUT = scanner.nextLine (); // read a line of the input string contents 
        of System.out.print ( "the input Number"); // printing tips 
        int Number = scanner.nextInt (); / / reads information input integer 

    } 
}

Note: import java.util.Scanner introduced in the top of the code; import here to mean the introduction of information

Guess you like

Origin www.cnblogs.com/lipu12281/p/12163914.html