No announcement
 

Concatenation

You can concatenate strings by using + operator or using the concat method.

Example:

StringConcatenationDemo.java

package com.codingnous.tutorial;

public class StringConcatenationDemo {

	public static void main(String[] args) {

		// Declare and initialize two strings
		String s1 = "quick_";
		String s2 = "read";

		// Concatenate s1 & s2 using + operator
		String s3 = s1 + s2;

		// Print the concatenated string s3
		System.out.println(s3);

		// Concatenate s1 & s2 using concat method
		String s4 = s1.concat(s2);

		// Print the concatenated string s4
		System.out.println(s4);

	}

}

Output
quick_read quick_read