在java中,如何从键盘输入到字符串中 BufferedReader类2113-JDK1.4import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;public class BoffReader {public static void main(String[]args){BufferedReader in=new BufferedReader(new InputStreamReader(System.in));try {String s=in.readLine();System.out.println(s);} catch(IOException e){e.printStackTrace();}}}Scanner类-JDK1.5以上5261import java.util.Scanner;public class Scanner1 {public static void main(String[]args){Scanner sc=new Scanner(System.in);String s=sc.nextLine();接受键盘字符串4102System.out.println(s);}}学习中1653=
java如何接收从键盘输入的字符串,Java有一个Scaer的工具类,它可以帮助我们接收从键盘输入的数据。
java 中怎样实现从键盘读入单个字符? 用Public class scannerimport java.util.Scanner;Scanner ObjectName=new Scanner(System.in);ObjectName.next();return String:the first characters between two delimiters.所以2113输入字符时只5261需输入一个字4102符,点enter或space,tab即可1653