String Concatenation
Advertisements
String Concatenation
There are two way to concat string object in java:
- By + (string concatenation) operator
- By concat() method
By + operator
Using Java string concatenation operator (+) you can combined two or more strings.
Example
class StringHandling { public static void main(String arg[]) { String s= "Java" + "Code"; System.out.println(s); } }
Output
JavaCode
By concat() method
concat() method is used to combined two strings.
Example
class StringHandling { public static void main(String arg[]) { String s1="Java"; String s2="Code"; String s3=s1.concat(s2); System.out.println(s3); } }
Output
JavaCode
Google Advertisment