此类用于连接使用定界符分隔的字符序列。
public class StringJoinerSample { public static void main(String[] args){ StringJoiner sj = new StringJoiner(", "); sj.add("Krishna"); sj.add("Raju"); sj.add("Satish"); sj.add("Pruthvi"); System.out.println(sj); } }
输出结果
Krishna, Raju, Satish, Pruthvi