Super friendly <br/>code & developer communities

Super friendly
code & developer communities

A place for coders and developers to share, learn and grow together.

Java Programming | Using Strings and concatenation of strings

This is a tutorial for using string and concatenation of strings in java. The program is given below that takes name and surname of the user as input and makes full name and prints hello message. The program is extendable. Go enjoy the program. Lets begin…

Program for string and concatenation of string in java.

//import Scanner as we require it.
import java.util.Scanner;

// the name of our class its public
public class Strings {
	//void main
		public static void main (String[] args)
			//declare variables
			String name,surname,fullname;
			//print message
			System.out.println("Enter your name:");
			//Take input
			Scanner input = new Scanner(;
			 name =;
			 System.out.println("Enter your surname:");
			 surname =;

			 fullname = name;
			 fullname = fullname.concat(" "+surname);

			//print the message
			System.out.println("Hello ,"+fullname);


Enter your name:
Enter your surname:
Hello ,abc xyz

How it works
1. You enter your name and surname
2. Program does concatenation of your name and surname.
3. Program says hello to you.

Extending it
The program can be extended by using the concept in any program.
Remember this is a basic part of java which can be used in any program.

1. Import the Scanner.
2. Declare the class as public
3. Add the void main function.
4. Declare Strings.
5. Declare input as Scanner.
6. Add system.out.println() function with the message to enter necessary inputs .
7. Take the inputs and save it in variables.
8. Call Concat() function.
9. Add system.out.print() function to hello message.

At the end.
You learnt creating the Java program for Using Strings and concatenation of strings. So now enjoy the program.

P.S. If you have any questions, click here to join our community and feel free to ask any questions.