Concatenate Two Strings

From CodeCodex

Revision as of 21:59, 14 March 2007 by 206.160.140.2 (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.

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>