我现在能取出这样一个LIST集合 
1,a
1,b
1,c
1,d
2,e
2,f
-------------------------
然后想转成下面形式的 各位有什么高见 
1,a,b,c,d
2,e,f

解决方案 »

  1.   

    这个不是,我只是举的例子。。是LIST集合
    第一列 会有重复值出现。
    我就是想要 把重复的都放到一起
    有点类似SQL的 列转行
      

  2.   

    看不懂LZ的题目
    你这LIST里存放的对象类型是什么啊1和2 又是什么东西?
    LIST只能存一列,你怎么存两列?
      

  3.   

    public static  void t(){
    List<String> strs = new ArrayList<String>();

    strs.add("1,a");
    strs.add("1,b");
    strs.add("1,c");
    strs.add("1,d");
    strs.add("2,e");
    strs.add("2,f");
    Set hashSet = new HashSet();
    for(int i=0; i<strs.size(); i++)
    {
    String aaa = strs.get(i).split(",")[0];
    hashSet.add(aaa);
    }

    Iterator it = hashSet.iterator();
    while(it.hasNext()){
    String text="";
    String haid=(String)it.next();
    for(int i=0; i<strs.size(); i++)
    {
    String aaa = strs.get(i).split(",")[0];
    if(haid.equals(aaa)){
    text+=strs.get(i)+",";
    }
    }
    System.out.println(text);
    }
    }
    public static void main(String[] args){
    t();
    }