资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

collection 转换为数组请高手们指点,在线等!

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

public   class   DisplaySet   {  
      private   String   key;  
      private   String   value;  
      public   DisplaySet()   {  
      }  
      public   void   setKey(String   key){  
          this.key   =   key;  
      }  
      public   String   getKey(){  
          return   this.key;  
      }  
      public   void   setValue(String   value){  
          this.value   =   value;  
      }  
      public   String   getValue(){  
          return   this.value;  
      }  
  }  
  //////////////////////  
    public   double[][]   converseCToA(Collection   cl)   {  
                int   sum   =   cl.size();  
                Iterator   it   =   cl.iterator();  
                double[][]   XYData   =   {};  
                int   i   =   0;  
                try{  
                    while   (it.hasNext()   &&   i   <   sum)   {  
                        DisplaySet   keys   =   (DisplaySet)   it.next();  
                        System.out.println(Double.valueOf(keys.getKey()).doubleValue());  
                        XYData[0][0]   =   Integer.parseInt(keys.getKey());//?  
                        XYData[1][0]   =   Integer.parseInt(keys.getValue());  
                        i++;  
                    }  
                }catch(Exception   e){  
                    System.err.println(e.getMessage());  
                }  
                return   XYData;  
        }  
  在执行到?号的地方就抛出异常请问怎么回事及解决办法,多谢

网友回答:

发表者:tiger_shi

是不是没有分配空间啊?double[][]   XYData   =   {};

发表者:zhaoqiubo

我感觉也是没有分配控件造成的,另外,我认为在没有效率的特别要求下,可以不使用2维数组。完全可以定一个一个类储存key和value值,然后使用ArrayList或者Vector储存这个类的实例。。也可以用对象数组。。

发表者:fireredfox

你不是有collection.size()吗?  
   
  这样写       double[][]   XYData   =   new   double[sum][sum];


 

 
热门推荐笔记本: IBM笔记本
相关文章:
笔记本相关:
IT技术文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved