A good answer might be:

Yes: in output statements like this:

System.out.println( "Result is:" + result );

+ Operator

The "+" operator is a short way of asking for concatenation. (If result is a number, it is converted into characters before the concatenation is done).

The code snippet could be written like this:

String first = "Kublai" ;
String last  = " Khan" ;
String name  = first + last;

This does the same thing as the first version (plus an optimization which can be ignored for now). Only Strings have short-cut ways of doing things.

String concatenation, done by concat() or by +, always constructs a new object based on data in other objects. Those objects are not altered at all.


QUESTION 9:

Say that the following statement is added after the others:

String reversed = last + first;

Does it change first, last, or name?

Click Here after you have answered the question