在Java中可以使用加号操作符(+)来拼接两个字符串。例如:
String str1 = "Hello";
String str2 = "World";
String result = str1 + " " + str2;
System.out.println(result); // Output: Hello World
另外,还可以使用concat()
方法来拼接字符串。例如:
String str1 = "Hello";
String str2 = "World";
String result = str1.concat(" ").concat(str2);
System.out.println(result); // Output: Hello World
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:java两个字符串交叉拼接怎么实现