String Interpolation in Various Programming Languages

Many times we need to embed values from variables or constants in a string to display that string on screen. It is not necessary to to use concatenate function each time. There are shortcuts in many programming languages to achieve this embeding.

Swift

In swift, you have to enclose the variable or constant inside brackets () and escape it with a backslash character.

Result will be :

Hi! My name is Jitendra. I am a Developer.

Kotlin

in Kotline, you have to append variable name with dollar Sign $ inside string template.

Result will be :

Hi! My name is Jitendra. I am a Developer.

JAVA

Result will be :

Democracy is a government of the People.

JAVAScript

In javascript,  ${ } format is used. Anything can be placed inside brackets including functions, calculations, variables, constants.

PHP

In PHP,  variables can be embedded by appending dollar sign to variable. {} curly brackets can also be used as extra for easy differentiation with other text.