Summary : We are going to describe how to concatenate of two string. we have use for concat() method, this method joints of two string first-to-end.
Concatenate Two Strings in java
We are going to describe how to concatenate of two string. we have use for concat() method, this method joints of two string first-to-end.
Description of below example:-
In this below example we have taken two String string and string2.This keyword returns of String followed by String arguments Characters. After that we have use string.concat(string2) method it means add the two String first-to-end. You can use anther way method "+" operator you can easily add of first-to-end string.
There are two method add of String:-
- String string3 = string + " "string;
- String string3 = string.concat(string2);
Example
package StringExample; public class TwoStringConcatenate { public static void main(String[] args) { String string ="rose india"; String string2="technologies pvt limited"; String string3 = string.concat(string2); //Another way Add of two String /* String string3=string + ""+string2; */ System.out.println("Concatenated string: " + string3); } }
Output