如何使用Java连接两个字符串?

您可以使用concat()方法连接两个字符串。

示例


public class ConcatinatedStrings {
   public static void main(String args[]) {
     
      String str1 = new String("nhooo");
      String str2 = new String(".com");
      String res = str1.concat(str2);
      System.out.println(res);
   }
}

输出结果

nhooo.com