4.Java语言的字符串拼接符

“+”符号拼接法

String expletive = "Expletive";
String PG13 = "deleted";
String message = expletive + PG13;

join方法

String all = String.join(" / ", "S" , "M" , "L" , "XL");
输出:"S / M / L / XL"

repeat方法

String repeated = "Java".repeat(3);
输出:"JavaJavaJava"

原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/java/javahigh/2347.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注