标题:急救!
只看楼主
lvsong1988
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-9-18
 问题点数:0 回复次数:1 
急救!
我用的是j2sdk1.4.2 在这里我可不可以像C语言那样用for循环语句向数组中输入数据,再用for循环给输出?
如:public class bijiao{
    public static void main(String args[]) throws IOException{
        int a[];
        a[10]=new int[10];
        System.out.println("Please input the numbers:");
        for(int i=0;i<10;i++)
            int a[i]=(int)System.in.read();
            System.in.skip(2);
        for(int i=0;i<10;i++)
            System.out.print(a[i]+"   ");
    }
}
这是我试着写的,但是有错误,该怎么样修改呢?
搜索更多相关主题的帖子: 急救 
2008-09-26 15:48
elan1986
Rank: 6Rank: 6
等 级:贵宾
威 望:18
帖 子:458
专家分:407
注 册:2007-12-17
得分:0 
import   javax.swing.*;   
   
  public   class   test1   
  {   
  public   static   void   main(String[]   args)   
  {   
      int[] array=new int[11];
      for(int i=1;i<array.length;i++)
      {
      String   input   =   JOptionPane.showInputDialog   
      ("请输入第"+i+"个数字:");   
   
      int   age   =   Integer.parseInt(input);   
      array[i]=age;  
      }
      for(int n=1;n<array.length;n++)
          System.out.println(array[n]);
  }   
  }
2008-09-26 18:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-235342-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.232681 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved