串联字符串的Java程序。
String类的 concat() 方法将指定的字符串连接到该字符串的末尾。
示例
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
//打印str1-
String str1 = "self";
System.out.println(str1);
//打印与str1串联的str2-
String str2 = str1.concat(" learning");
System.out.println(str2);
//打印与str2(和str1)串联的str3-
String str3 = str2.concat(" center");
System.out.println(str3);
}
}输出结果
self self learning self learning center
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短