How to concatenate strings in Java
In this tutorial, we are going to learn about how to concatenate string in Java with the help of examples.
Concentration means joining of two strings into a single string.
To concatenate strings, we can use the plus
+ operator in Java.
Here is an example:
String first = "Code"; String last = "examples"; String combine = first + last; System.out.println(combine);
Using concat() method
Similarly, we can also use the
concat() method to concatenate one string with another string.
String name = "Code"; System.out.println(name.concat("Java"));