【发布时间】:2021-10-01 03:37:11
【问题描述】:
我想从控制台写,但我没有任何结果或任何错误。 我的代码:
public class ReadFromInput {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
System.out.println("Your name: ");
for(int i=0; i<args.length; i++) {
In in = new In(args[i]);
String s = in.readAll();
System.out.print("My name is"+s);
}
}
【问题讨论】:
-
运行程序时究竟发生了什么?
-
看起来你应该在
System.in上使用Scanner -
@tgdavies 什么都没有:D.
-
所以你甚至没有看到
Your name:? 确切地你是如何构建和运行程序的? 正是运行时你看到了什么? -
@tgdavies 我看到了“你的名字”的字样,但我写不出来。我使用 Eclipse IDE