Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
The process of merging data literals is one of the core applications of concatenation. The general syntax to achieve concatenation is given below:
(data type)(concatenation operator)(data type)=(concatenated expression)
Consider two strings: hello=”hello” and world=” world”
The concatenation syntax in different programming languages is given below.
hello & world : VB,VB.NET and Ada
strcat(hello, world) : C, C++
hello.world: Perl, PHP
hello || world : REXX, SQL
hello || world : FORTRAN
hello ++ world : Erlang, Haskell
hello ^ world : Ocaml, Standard ML, F#
hello+world : Java
In addition to strings, concatenation can be applied to any other data type, including objects. For simple data types such as binary, integer, floating point, character and Boolean, prior to concatenation string type conversion is applied. Concatenation can then be easily applied using one of the above operators. For objects, concatenation implies the concatenation of data contained within the objects and is generally possible only if the structure of the objects is the same or if both objects belong to the same class. A method can be incorporated into the class to concatenate each and every data member of both objects and return the computed result to the main routine.
Do you work in the tech industry? Help us learn more about why the gender gap still exists in tech by taking this quick survey! Survey respondents will also be entered to win a $100 Amazon Gift Card!