Concatenate Two Strings

From CodeCodex

Revision as of 21:59, 14 March 2007 by (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This code demonstrates how to concatenate two strings. This is also called joining two strings, or simply putting two strings together.



<HIGHLIGHTSYNTAX lang="java122"> String a = "A"; String b = "B"; String c = a + b; //concatenates a and b System.out.println(c); //prints "AB" </HIGHLIGHTSYNTAX>


<HIGHLIGHTSYNTAX lang="javascript"> var a = 'A'; var b = 'B'; var c = a + b; //concatenates a and b alert(c); //prints "AB" </HIGHLIGHTSYNTAX>