在java里面怎样实现两个字符串的连接操作

2024-11-23 00:04:10
推荐回答(2个)
回答1:

1.String a = "abc";
String b ="def";
String c = a+b;
2.StringBuffer a =new StringBuffer("acb");
StringBuffer b =new StringBuffer("123");
a.append(b);
3.String a = "abc";
String b ="def";
String c = a.concat(b);

第三种方法,必须是String 类型

回答2:

string a="a";
string b="b";
string c=a+b;