Fork me on GitHub

object转化为string

 1 package common;
 2 
 3 import java.util.ArrayList;
 4 import java.util.List;
 5 
 6 public class DataZh {
 7    
 8     
 9     public static List<String> ObjecttoString(List<Object> o)
10     {
11         List<String> x = new ArrayList<String>();
12         for(Object oj: o){
13             x.add(oj.toString());
14         }
15         return x;
16     }
17     
18     
19     public static List<String[]> ObjectAtoStringA(List<Object[]> o)
20     {
21         List<String[]> x = new ArrayList<String[]>();
22         for(Object[] oj:o){
23             String[] temp = new String[oj.length];
24             for(int i = 0; i < oj.length; i++){
25                 temp[i] = oj[i].toString();
26             }
27             x.add(temp);
28         }
29         return x;
30     }
31 //    for(Object o : array)
32 //    { System.out.println(o);}
33 //    这是jdk1.6里面新增的功能:增强的for循环.
34 //    其实就是一个一个的把array里面的元素取出来,o就是你取出来的那个元素.
35 //36 //    for(int i=0;i<array.size();i++){
37 //            Object o = array.get(i);
38 //
39 //            System.out.println(o);
40 //
41 //    }
42 //    是一样的.
43 //    }
44     
45 }

 

posted @ 2015-08-11 20:54  ZZZZW  阅读(237)  评论(0编辑  收藏  举报
AmazingCounters.com