Concatenate Three Strings

This program concatenates three strings and prints them.

Problem Statement

Write a Java program that concatenates three strings.

Source Code

1 public class ConcatenateThree {
2 public static void main(String[] args) {
3 String s1 = "Eduinq";
4 String s2 = "Java";
5 String s3 = "Programs";
6 System.out.println(s1 + " " + s2 + " " + s3);
7 }
8 }

Program Output

Eduinq Java Programs

Explanation

Three string variables are declared and concatenated together with spaces using the + operator, demonstrating concatenation of multiple strings.

Quick Links to Explore