String Concatenation by concat() Method



You can concatenate two strings using the concat() method of the String class. This class concatenates the specified string to the end of this string.

Example

Live Demo

public class Test {
   public static void main(String args[]){
      String str1 = "Krishna";
      String str2 = "Kasyap";
      System.out.println(str1.concat(str2));
   }
}

Output

krishnaKasyap
Updated on: 2020-02-26T05:57:18+05:30

192 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements