Yes.
concat()
Method 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 performs String
concatenation.
A new String
is constructed
using the data from two other String
s.
In the example,
the first two String
s
(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 String
s are NOT changed by the action of concat()
.
A new String
is constructed that contains the characters "Red Rose".
(Review:) Have you seen String
concatenation before?