Java Program to Display Full Name of user

Write a Java program to accept first name, middle name and surname in three different strings and then concatenate the three strings to make full name.

Source Code
import java.util.Scanner;

public class FullNameString {

	public static void main(String[] args) {

		Scanner input = new Scanner(;
		System.out.print("Enter first name :: ");
		String firstName = input.nextLine();
		System.out.print("Enter middle name :: ");
		String middleName = input.nextLine();
		System.out.print("Enter surname :: ");
		String lastName = input.nextLine();
		// Here StringBuffer is used to combine 3 strings into single
		StringBuffer fullName = new StringBuffer();
		fullName.append(" ");   // For space between names
		fullName.append(" ");   // For space between names
		System.out.println("Hello, " + fullName);
Enter first name :: Rahul
Enter middle name :: S.
Enter surname :: Tamkhane
Hello, Rahul S. Tamkhane

"Coding Hub - Learn to code" app now available on Google Play Store