Android中List转换为String字符串,String字符串转换数组。

//把List集合转换为字符串用&隔开
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
    stringBuffer.append(list.get(i).toString().trim() + "&");
}
String s = stringBuffer.substring(0, stringBuffer.length() - 1).toString();

//把String字符串转换为数组用List集合存入

ArrayList list = new ArrayList();
String[] split = symptom.split("&");
for (int i = 0; i < split.length; i++) {
    list.add(split[i]);
}

你可能感兴趣的:(java,y)