We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

concat() method of String class in Java

In Java, there are two ways to concatenate two strings. You can use the concat method or the plus “+” character. Sun developers are using plus operator inside the body of concat method. concat method is used for achieving more readability.

The method return type is a String with the value of the String passed in to the method appended to the end of the String used to invoke this method.


  1. public String concat(String temp);

Let us take an example to understand this method in deep :

  1. public class DemoConcat{
  3. public static void main(String args[]) {
  5. String s = "Strings are easy";
  7. s = s.concat(" to learn");
  9. System.out.println(s);
  11. }
  13. }


Strings are easy to learn

Facebook Comments
(Visited 1 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: