Difference between revisions of "Concatenate Two Strings"

From CodeCodex

 
 
Line 1: Line 1:
This code demonstrates how to concatenate two strings. This is also called joining two strings, or simply putting two strings together.
+
#REDIRECT[[Concatenate two strings]]
==Implementations==
+
===Java===
+
<HIGHLIGHTSYNTAX lang="java122">
+
String a = "A";
+
String b = "B";
+
String c = a + b;      //concatenates a and b
+
System.out.println(c); //prints "AB"
+
</HIGHLIGHTSYNTAX>
+
 
+
===JavaScript===
+
<HIGHLIGHTSYNTAX lang="javascript">
+
var a = 'A';
+
var b = 'B';
+
var c = a + b; //concatenates a and b
+
alert(c);      //prints "AB"
+
</HIGHLIGHTSYNTAX>
+
 
+
[[Category:Java]]
+
[[Category:JavaScript]]
+
 
+
[[Category:String]]
+

Latest revision as of 22:04, 14 March 2007