怎么在用java语言在eclipse控制台输出手动输出字符串

数字的是定义那个 Scanner 什么的,字符串怎么弄

  可以用Scanner类的next方法实现:

public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  System.out.print("请输入:");
 String text = sc.next();
  System.out.print(text);
 }

  它是以前的StringTokenizer和Matcher类之间的某种结合。由于任何数据都必须通过同一模式的捕获组检索或通过使用一个索引来检索文本的各个部分。于是可以结合使用正则表达式和从输入流中检索特定类型数据项的方法。
  这样,除了能使用正则表达式之外,Scanner类还可以任意地对字符串和基本类型(如int和double)的数据进行分析。
  借助于Scanner,可以针对任何要处理的文本内容编写自定义的语法分析器。
  Scanner是SDK1.5新增的一个类,可是使用该类创建一个对象.  
Scanner reader=new Scanner(System.in);  
然后reader对象调用下列方法(函数),读取用户在命令行输入的各种数据类型:  
next.Byte(),nextDouble(),nextFloat,nextInt(),nextLine(),nextLong(),nextShot()  
上述方法执行时都会造成堵塞,等待用户在命令行输入数据回车确认.例如,拥护在键盘输入12.34,hasNextFloat()的值是true,而hasNextInt()的值是false. NextLine()等待用户输入一个文本行并且回车,该方法得到一个String类型的数据。

温馨提示:内容为网友见解,仅供参考
第1个回答  2013-10-31
Scanner都能啊!
Scanner sc=new Scanner(System.in);
sc.next();//这个返回的就是字符串
sc.nextInt();//这个返回的就是Int类型的
你去看看JDK API文档 看看Scanner这个类的方法,你就知道了本回答被提问者采纳
第2个回答  2015-09-22
输出用system.out.println("字符串");输入用Scanner cin = new Scanner(new BufferedInputStream(System.in));
第3个回答  2013-10-31
Scanner sc = new Scanner(System.in);
String text = sc.nextLine();
第4个回答  2013-10-31
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("请输入:");
String text = sc.next();
System.out.print(text);
}
相似回答