说明:很遗憾,组装的时候只能遍历。
方法:
public static String listToString(Listlist){ if(list==null){ return null; } StringBuilder result = new StringBuilder(); boolean first = true; //第一个前面不拼接"," for(String string :list) { if(first) { first=false; }else{ result.append(","); } result.append(string); } return result.toString();}
public static ListstringToList(String strs){ String str[] = strs.split(","); return Arrays.asList(str);}
参考: