Java String concatenation with + operator

Introduction

The + operator concatenates two strings, producing a String object.

We can chain together a series of + operations.

For example, the following fragment concatenates three strings:

String age = "9";  
String s = "He is " + age + " years old.";  
System.out.println(s); 

This displays the string "He is 9 years old."




PreviousNext

Related