Java String concat() method

FacebooktwittertumblrFacebooktwittertumblr

This is one of the articles from our Java Tutorial for Beginners.


The Java String concat() method

The concat() method in Java allows us to add one String to the end of another. For example, one sentence to the end of another sentence. We mentioned this method back in the article "Concatenation in Java."

The Syntax of the Method:

Example:

If you run this code on your computer, you will see the following in the console:

I have a goal this year. I want to become a Java programmer.

Commentary:

Because of this line of code,

  • "I want to become a Java programmer." was added to the value of the "sentence" variable "I have a goal this year."
  • and as a result, the variable sentence received a new value, which is "I have a goal this year. I want to become a Java programmer."

 


You can find more articles in our Java Tutorial for Beginners. 

FacebooktwittertumblrFacebooktwittertumblr

FacebooktwittertumblrFacebooktwittertumblr
Самоучители--узнать детальнее--