Import java.io.BufferedReader; Import Java.io.ioxception; Import Java.Io.InputStreamReader; Import java.util.Scanner; IC Static Void Main (String [] args) {// Main method Chartest () ; // Call the System.in method readTest (); // Call the readTest method scannertest (); // call the scannertest method}/*** System.in and System.out method* Disadvantages 1: This method can get input from the keyboard input from the keyboard The characters, but only for the acquisition of one character* Disadvantage 2: Only the Char type is obtained. If you want to get int, float and other types of input, it is more troublesome. */ Public Static void Chartest () {Try {System.out.print ("Enter a Char:"); Char I = (Char) System. Chinese.read (); : " + i);} Catch (IOEXCEption E) {e.printstacktrace ();} /*** inputStreamReamReader and bufferedReader method* advantage: you can get the string input of the keyboard* disadvantage: how to obtain it, float The types of equal types still need to be converted*/ Public Static void Readtest () {System.out.println ("Readtest, Please Enter Data:"); ; // New Constructed InputStreamReader ObffredReadreader Brr = new bufferedReader (is); // The method of using the constructor is passed to the TRY {// in the method in the bufferedReader. There is a IOEXCEPITON in this method that needs to capture the string name = bricAdline (); T: " + name);} Catch (IOEXCEPTION E) {e.printstacktrace ();}} /*** Scanner class* advantage 1: you can get the string input of keyboard input* advantage two: there is a ready -made int, float, etc. Type data is very powerful and very convenient; */ Public Static Void Scannertest () {Scanner Sc = New Scanner (System.in); System.out.println ("ScannerTest, Please Enter Name:"); String e = SC .nextline (); // Read the string type input system.out.println ("Scannertest, Please Enter Age:"); int Age = sc.nextint (); // Read the integer input system.out.println ("Scannertest, PLEASE ENTER SALALY:"); Float Salar = sc.nextfloat (); // Read the FLOAT type input system.out.println ("Your Information is as below:"); System.out.pr. intln (" Name: " +name +"/n " +" age: " +Age +"/n " +" salary: " +salary);}} Summarize:
To get the input in the keyboard:
Python provides, there is raw_input () in python2, and python3 has input ().
C provides the scanf () function
C ++ provides a cin () function to get the keyboard input
There is no ready -made function in Java to obtain the keyboard input, but it can still be implemented by the above methods. Among them, the method three should be the simplest and most convenient.