Print Username Program in java

In this post, we will learn Print Username Program in java Programming language.


Jeffy, who is going to complete the higher education this year needs to create a simple application that accepts the name of a person and welcomes them with a message along with their name. She wants to read the data using the class “Scanner”. Implement this scenario using Java.

Sample Input 1:

Enter the name:


Sample Output 1:

Welcome Johnson.

Sample Input 2:

Enter the name:

Stain Polson

Sample Output 2:

Welcome Stain Polson.

Print Username Program in java CODE:

import java.util.Scanner;
public class Username
    public static void main (String[] args) {
        Scanner sc=new Scanner(;
        System.out.println("Enter the name:");
        String name=sc.nextLine();
        System.out.println("Welcome "+name+".");

Leave a Comment