String concatenation is the process where we add 2 strings to make up a new string. This can be done using the addition operator ( + ).
For instance :
String firstName = “Lahiru”;
String lastName = “Hashan”;
String name = firstName + lastName;
check out the output :
Output : LahiruHashan
No space because there is no space given.
Check out these examples :
Playing around with numbers :
Now identify the new line and its output. Check what has happened.
Now the answer has pop up without the brackets. As you can see the execution is happening from left to right. Therefore here the addition of 2 floats takes place first and then addition to the string takes place. This is an important aspect of Java.
There is a special method in String class to add strings, named “concat” method. We will be discussing in the next tutorial along with the other String methods.
See you next time.
Excellent weblog right here! Additionally your site so much up very fast! What web host are you the use of? Can I am getting your affiliate hyperlink in your host? I want my site loaded up as fast as yours lol
LikeLiked by 1 person
Thank you @Alex
LikeLike
whoah this blog is wonderful i really like studying your articles. Keep up the good work! You know, a lot of individuals are looking round for this information, you can aid them greatly.
LikeLiked by 1 person
Thank you @Dianna. Sure I will try to upload new content …
LikeLike
I relish, cause I discovered just what I used to be having a look for. You have ended my four day lengthy hunt! God Bless you man. Have a great day. Bye
LikeLiked by 1 person
Thank you @Regina
LikeLike