public String concat(String str):将当前字符串和参数字符串拼接成为返回值新的。

 1 public class String01 {
 2     public static void main(String[] args){
 3         //拼接字符串
 4 
 5         String str1 = "Hello";
 6         String str2 = "World";
 7         String str3 = str1.concat(str2);
 8         System.out.println(str1);//Hello 原封不动
 9         System.out.println(str2);//World 原封不动
10         System.out.println(str3);//HelloWorld 新的字符串
11     }
12 }
13     

 

posted @ 2020-03-14 19:53  HuangBingQuan  阅读(421)  评论(0编辑  收藏  举报