提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
字符串方法concat。
public class Main { public static void main(String[] args) { /* from 时代Java公众号 - nowjava.com*/ String s1 = "Happy "; String s2 = "Birthday"; System.out.printf("s1 = %s\ns2 = %s\n\n",s1, s2); System.out.printf( "Result of s1.concat(s2) = %s\n", s1.concat(s2)); System.out.printf("s1 after concatenation = %s\n", s1); } }