The first: the use of Object Scanner
java.util.Scanner Import; public class TestInputOuput { public static void main (String [] args) { the System. OUT .println ( " Please enter: " ); Scanner InP = new new Scanner (. the System in ); String STR = InP .next (); . System OUT .println ( " you entered: " + str); } }
The second: the use of input streams and stream buffers
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TestInputOuput { public static void main(String[] args) throws IOException { System.out.println("请输入:"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("你输入了:"+br.readLine()); } }
Third: using the input box
javax.swing.JOptionPane Import; public class TestInputOuput { public static void main (String [] args) { String JOP = JOptionPane.showInputDialog ( null , " enter: " , " input box header " , JOptionPane.QUESTION_MESSAGE); the System. OUT .println ( " you entered: " + JOP); } }
An input box will pop up after the operation, in the input can be.