就是C的scanf   输出是System.out.pintln 输入呢?

解决方案 »

  1.   

    JOptionPane.showInputDialog(null,"");你说的是输入框?
      

  2.   

    别人问的是输入
    我一般用的是BufferedReader      BufferedReader in=new BufferedReader(new InputStreamReader(System.in) );
          try
             {
              String s=in.readLine();
             }catch(IOException e){};
     
      

  3.   

    JDK1.5以上有Scanner,去看看这个类
    或者BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
    double d = Double.parseDouble(br.readLine());
      

  4.   

    import javax.swing.*;
    String name=JoptionPane.showInputDialog(“str”);
      

  5.   

    不好意思
    没看清楚。
    int s[] = new int[10];
    Scanner in = new Scanner(System.in);
                    for(int i=0; i<10; i++) {
                       s[i] = in.nextInt();
                  }
    从键盘接收十个int 数
      

  6.   

    强烈BS 5楼和7楼...不try怎么用嘛
      

  7.   

    楼上的说的对,输入流特别要注意捕获异常
    经常是由于没有捕获IOException运行时会报错
      

  8.   


    Scanner keyboard = new Scanner(new InputStreamReader(System.in));
    area = keyboard.next().trim();
      

  9.   

    我的 blog 中有一篇文章,里面囊括了目前为止各种版本的 Java 控制台
    输入方式及其优缺点,有需要的话可以去看看。http://blog.csdn.net/bao110908/archive/2008/02/20/2108930.aspx
      

  10.   

    就是这个办法,一般来说常用IO输入流BufferedReader,java的api有详细说明
      

  11.   

    不是 main 方法里的  args 么。
      

  12.   


    args 是在运行前带入的参数,楼主所要的是在程序运行中的数据输入。
      

  13.   

    个人觉得Java的输入是有点烦。
      

  14.   

    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);
        }
      }
    这个行不?
      

  15.   

    有很多input   scaner   system.in  io  不過建議用stringbuffer
    很麻煩很麻煩
    java輸入超麻煩的
    不如在jsp里面輸入吧