How to concatenate two strings using Java?

Java 8Object Oriented ProgrammingProgramming

You can concatenate two Strings using the concat() method.

Example

Live Demo

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

Output

TutorialsPoint
raja
Published on 10-Jan-2018 14:46:12
Advertisements