Pasting Strings Together

When you use System.out.println() and work with strings in other ways, you can paste two strings together by using +, the same operator that is used to add numbers.

Note

You’ll probably see the term concatenation in other books as you build your programming skills, so it’s worth knowing. However, pasting is the term used here when one string and another string are joined together. Pasting sounds like fun. Concatenating sounds like something that should never be done in the presence of an open flame.

The + operator has a different meaning in relation to strings. Instead of performing some math, it pastes two strings together. This action can cause strings to be displayed together or make one big string out of two smaller ...

Get Sams Teach Yourself Java™ in 24 Hours, Sixth 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.