Overview


String concatenation (joining).

The simplest case where we join two Strings.
String s;
s = "Width: " + "10";
Here we join a String with an int. The result is a String.

Note: the first (left-most) value must be a String type.
String s;
s = "Width: " + 10;
We can join many elements.

Note: the first (left-most) value must be a String type.
String s;
s = "Width: " + 10 + " " + "Height: " + 2;
Generally the elements will not be literal/constant values but rather dynamic ones as shown here.
String s;
Rectangle rec = getRec1();
s = "Width: " + rec.getWidth();