package demo; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class ListDemo { public static void main(String[] args) { String str = "A,B"; // 字符串转List List<String> list = new ArrayList<>(Arrays.asList(str.split(","))); list.add("C"); // List转字符串 String line = String.join(",", list); System.out.println(line); // A,B,C } }