package ;
import ;
import ;
import ;
public class Main {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
("0");
("1");
("2");
("3");
("4");
("5");
("6");
("7");
("8");
("9");
((",",list));
(().collect((",")));
}
}
效果:
0,1,2,3,4,5,6,7,8,9
0,1,2,3,4,5,6,7,8,9
关键点:
(",",list)
().collect((","))
参考
- Convert a List to a Comma-Separated String in Java 8