go to previous page   go to home page   go to next page

Answer:

Yes.

The parts of the statement match the documentation correctly:

String name = first.concat( last ); 
 ----+----    --+-- --+--  --+--
     |          |     |      |
     |          |     |      |
     |          |     |      +---- a String reference parameter
     |          |     |
     |          |     +----- the name of the method
     |          |
     |          +----- dot notation used to call an object's method.
     |
     +----- the method returns a reference to a new String object

The concat() Method

Concat() Method Call

The concat method performs String concatenation. A new String is constructed using the data from two other Strings. In the example, the first two Strings (referenced by first and last) supply the data that concat() uses to construct a third String (referenced by name.)

String first = "Red " ;
String last  = "Rose" ;
String name  = first.concat( last );

The first two Strings are NOT changed by the action of concat(). A new String is constructed that contains the characters "Red Rose".

The picture shows the operation of the concat() method before the reference to the new object has been assigned to name.


QUESTION 10:

(Review:) Have you seen String concatenation before?


go to previous page   go to home page   go to next page