How to Concatenation in Java Using + Operator

Problem:- How to Concatenation in Java Using + Operator or concatenation in java example java program for concatenating string or java program for print multiple values in one statement. String Concatenation in Java. using + operator.

Check This:- HackerRank solution for C++ Domain.

Explanation:- Concatenation means adding two or more values, Java we have plus ( + ) operator for Concatenation two same and different type of values. The need of Concatenation and why we use?. The simple answer is when we need to add the values and printing the multiple the values in a single line we use Concatenation. Below is the example of Concatenation so you can understand very well.

Example:- Suppose you want to print the output of Factorial of number 5 or any other number if you don't use Concatenation then you need multiple print statement for printing the output of Factorial check the below two examples for printing the output of Factorial. factorial of 5 is 120.

Without using Concatenation

System.out.println("Factorial of  ");
System.out.println(" is ");
System.out.println( fact );

So without using Concatenation your output will be 

Factorial of

Using Concatenation

System.out.println( "Factorial of  " + number + " is " + fact );

Now the output of the program will be 

Factorial of  5 is 120

Here number and fact are variable. You notice that both the output of the program.

How to Concatenation in Java Using + Operator

class Program3
public static void main(String[] args)
System.out.println("java "+"developer");
System.out.println("Number is"+20);
System.out.println("Number is"+20+20);
System.out.println("Number is"+(20+20));
System.out.println("20+ is the Number");
System.out.println(20+20+"is the Number");


How to Concatenation in Java Using + Operator

You May Also See

1. Java Program To Print ASCII Value Of Character

2. Java Program To Find Area Of Triangle

3. Java Program to Convert a person's name in Abbreviated

4. Java Program For Calculate A Simple Interest

5. Java Program For Find The Gross Salary Of An Employee
Prashant Chaturvedi

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

1 comment:

  1. Anonymous3/30/2016

    Thanks For Understable Code