concat() method in java is used to concatenates multiple strings. This method adds the string at the end of the given string and returns the full combined string.
concat() Method Example
public class S4GConcatExample { public static void main(String[] args) { String str="Study4Geeks"; String str2="is Online"; String str3="Learning Platform"; String str4=str.concat(str2).concat(str3); System.out.println(str4); } }
output:
Study4Geeksis OnlineLearning Platform
concat() Method Example 2
public class S4GConcatExample { public static void main(String[] args) { String str="Study4Geeks"; String str2="is Online"; String str3="Learning Platform"; // Concatenating Space between strings String str4 = str.concat(" ").concat(str2). concat(" ").concat(str3); System.out.println(str4); } }
output:
Study4Geeks is Online Learning Platform