AP® Computer Science A glossary

String concatenation

Also called: concatenation

Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods

Joining strings with + or +=, which creates a new String. Primitives are converted to text and objects call toString.

Appears in the course and exam description (CED): 1.15.A.41.15.A.5

Java works left to right: once a String appears, + joins text. "Score: " + 4 + 5 is "Score: 45", but 4 + 5 + " pts" is "9 pts".

System.out.println("Score: " + 4 + 5);
System.out.println(4 + 5 + " pts");

Output:

Score: 45
9 pts
Learn it properly, with a checkpoint 1.15 String Manipulation

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure