将List转换为二维数组(result)

 

result的数据结构为List<Map<String,Object>>

 

            //将List转换为二维数组String[][]
              String[][] z = new String[result.size()][];  
              
                 for(int i=0;i<z.length;i++){
                  
                  Map m = (Map)result.get(i);
                  Set set = m.keySet();
                  z[i] = new String[m.size()];
                  Iterator it =set.iterator();
                
                 for(int j=0;it.hasNext();j++){
                     String s = (String)it.next();
                     if(m.get(s)!=null){
                         z[i][j] =m.get(s).toString();
                     }
                  }
              }

 

posted on 2015-04-26 21:51  小忙  阅读(14651)  评论(0编辑  收藏  举报

导航