import java.util.*; public class Input { public static void main(String args[]) { Scanner in=new Scanner(System.in); System.out.println("你的名字"); String name =in.nextLine(); System.out.println("你的年龄"); int age =in.nextInt(); System.out.println("Hello,"+name +" "+age); } } 这个行不?
我一般用的是BufferedReader BufferedReader in=new BufferedReader(new InputStreamReader(System.in) );
try
{
String s=in.readLine();
}catch(IOException e){};
或者BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
double d = Double.parseDouble(br.readLine());
String name=JoptionPane.showInputDialog(“str”);
没看清楚。
int s[] = new int[10];
Scanner in = new Scanner(System.in);
for(int i=0; i<10; i++) {
s[i] = in.nextInt();
}
从键盘接收十个int 数
经常是由于没有捕获IOException运行时会报错
Scanner keyboard = new Scanner(new InputStreamReader(System.in));
area = keyboard.next().trim();
输入方式及其优缺点,有需要的话可以去看看。http://blog.csdn.net/bao110908/archive/2008/02/20/2108930.aspx
args 是在运行前带入的参数,楼主所要的是在程序运行中的数据输入。
public class Input
{
public static void main(String args[])
{ Scanner in=new Scanner(System.in);
System.out.println("你的名字");
String name =in.nextLine();
System.out.println("你的年龄");
int age =in.nextInt();
System.out.println("Hello,"+name +" "+age);
}
}
这个行不?
很麻煩很麻煩
java輸入超麻煩的
不如在jsp里面輸入吧