| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 706 人关注过本帖
标题:急救!
只看楼主 加入收藏
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
快速回复:急救!
数据加载中...
 
   



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

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