程序需要实现,从键盘输入数字,存到一个实数型数组中,中间可以通过按某个键通知程序结束输入,然后程序输出显示刚才输入的数字!我是新人,水平不行,谢谢各位了!

解决方案 »

  1.   

    public static void main(String[] args) {
        DataInputStream in =
          new DataInputStream(
            new BufferedInputStream(System.in));
        String s;
        try {
          while((s = in.readLine()).length() != 0)
            System.out.println(s);
          // An empty line terminates the program
        } catch(IOException e) {
          e.printStackTrace();
        }
      }
      

  2.   

    http://community.csdn.net/Expert/topic/4952/4953000.xml?temp=.8086206看看这个帖子 里面的代码对你很有用
      

  3.   

    数字还是你自己来转换吧,给你个例子,遇到 bye结束import java.io.*;
    public class test 

       
      
      public static void main(String args[]) 
         {
          System.out.println("please input String:");
        try {
         DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
        String s;
        
          while((s = in.readLine()) != null)
          {
            if(s.equals("bye")) return;
            System.out.println(s);
          }
          
        } catch(IOException e) {
          e.printStackTrace();
        }    } 
       
    }
      

  4.   

    import java.io.*;
    public class test 

    public static void main(String args[]) 
    {
    String[] aryS ;
    System.out.println("please input String:");
    try {
    DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
    String s; while((s = in.readLine()) != null)
    {
    if(s.equals("bye")) return;
    int l ;
    for(int i=0;i<s.length();i++){
    if(s.charAt(i)==',')
    l++;
    }
    aryS = new String[l+1];
    aryS = s.split(",");
    System.out.println(s);
    } } catch(IOException e) {
    e.printStackTrace();
    } } }
      

  5.   

    import java.io.*;
    public class test 

    public static void main(String args[]) 
    {
    String[] aryS ;
    System.out.println("please input String:");
    try {
    DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
    String s; while((s = in.readLine()) != null)
    {
    if(s.equals("bye")) return;
    int l =0;
    for(int i=0;i<s.length();i++){
    if(s.charAt(i)==',')
    l++;
    }
    aryS = new String[l+1];
    aryS = s.split(",");
    //System.out.println(s);
    for(int j=0;j<aryS.length;j++){
    System.out.println( aryS[j] );
    }
    } } catch(IOException e) {
    e.printStackTrace();
    } } }