String Concatenation In Java Example
Chapter:
String Handling
Last Updated:
10-06-2016 19:25:07 UTC
Program:
/* ............... START ............... */
public class JavaStringConcatenation {
public static void main(String args[]) {
String str = "developed";
String s = "Java " + str + " by Sun Microsystems.";
System.out.println(s);
}
}
/* ............... END ............... */
Output
Java developed by Sun Microsystems.
Notes:
-
String concatenation forms a new string that is the combination of multiple strings.
- Two ways to concatenate string in Java.
- 1. By using + (string concatenation) operator.
- 2. By concat() method.
Tags
String Concatenation, Java