(1)Scanner是方法之一,如下
import java.util.Scanner;
public class Demo{
public static void main(String[] args){
System.out.println("请输入");
Scanner s = new Scanner(System.in);
String string = s.next();
System.out.println(string);
}
}
(2)BufferedReader,如下
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Demo{
public static void main(String[] args){
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入A:");
String a=br.readLine();
System.out.println(a);
}catch(Exception e){
}
}
}
(3)通过弹框提示输入
import javax.swing.JOptionPane;
public class Demo{
public static void main(String[] args){
String str = JOptionPane.showInputDialog("请输入");
System.out.println(str);
}
}
望采纳...
温馨提示:答案为网友推荐,仅供参考