1, Output: System.out *.
* Println () is an abbreviation of the print line, and line represents an output;
* Print () indicates an output not wrap;
* Printf () indicates the output format, the formatting parameters represented by the placeholder;
Placeholder | Explanation |
%d | Formatted output integer |
%x | Formatted output hexadecimal integer |
%f | Formatted output float |
%e | Floating point numbers formatted output scientific notation |
%s | Format string |
%% | Itself represents one percent |
2, type:
. 1 Package Test; 2 // Import statement is introduced into a class, . 3 Import java.util.Scanner; . 4 . 5 public class Test01 { // class name Test01 . 6 public static void main (String [] args) { . 7 / / create Scanner objects, passing System.in standard input stream. System.out represents the standard output stream. . 8 Scanner Scanner = new new Scanner (the System.in); . 9 // printing tips 10 of System.out.print ( "the Input your name:" ); . 11 //Reads and acquires a line of input character string, after the object has Scanner reads user input string using scanner.nextLine (); reads integer input by the user using scanner.nextInt (); Scanner automatically convert data types, therefore, no manual conversion. 12 is String name = scanner.nextLine (); 13 is // printing tips 14 of System.out.print ( "the Input your Age:" ); 15 // read a line of input and acquires an integer of 16 int Age = scanner.nextInt (); 17 // formatted output 18 is System.out.printf ( "the Hi,% S,% D you are \ n-" , name, Age); . 19 20 is } 21 is } 22 is
3. Summary:
JAVA output include: System.out.print () / printf () / println ();
JAVA objects Scanner provides easy input, reads the corresponding type can be used: scanner.nextLine () / nextInt () / nextDouble () / ......