×
☰ See All Chapters

String Concatenation in Java

We can concatenate only matching types. We cannot concatenate String with StringBuilder/StringBuffer. We cannot concatenate StringBuilder with StringBuffer.  We can concatenate String with only String. We can concatenate StringBuilder with only StringBuilder. We can concatenate StringBuffer with only StringBuffer.

String Concatenation

  1. By + (string concatenation) operator 

  2. By concat() method 

StringBuilder, StringBuffer Concatenation

By append() method : There are various overloaded  append() methods present in StringBuilder, StringBuffer classes.

string-concatenation-in-java-0
 

All Chapters
Author