需求中我需要把后台返回的一连串名字中间的逗号用空格替换,
现代码如下:
String name = “”;
//随机获取后台数据
Random random = new Random();
int ran = random.nextInt(response.size());
String doctorName = response.get(ran).getPATIENT_NAME();
//根据逗号切割数据
String[] temp = doctorName.split(",");
for (int i = 0;i<temp.length;i++){
//数据叠加且用空格替换
name += temp[i]+" ";
}
txtContentOne.setText(name);