14.3.6 Concatenating Strings
String
method concat (Fig. 14.7) concatenates two String
objects (similar to using the + operator) and returns a new String
object containing the characters from both original String
s. The expression s1.concat(s2)
at line 13 forms a String
by appending the characters in s2
to the those in s1
. The original String
s to which s1
and s2
refer are not modified.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.