String Concatenation Example Java Program


A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed (after creation). A string is generally understood as a data type and is often implemented as an array of bytes (or words) that stores a sequence of elements. A string may also denote more general arrays or other sequence (or list) data types and structures.



String Concatenation Example Program

import java.util.Scanner;

public class StringConcatenation{
	public static void main(String[] args){
	String result;
	Scanner in=new Scanner(;
	System.out.println("Enter the string1: ");
	String str1=in.nextLine();
	System.out.println("Enter the string2: ");
	String str2=in.nextLine();
    System.out.println("The resulting string is: "+result);

Sample Output

Output is:
Enter the string1:
Enter the string2:
The resulting string is: she eats