[Java] Main.java

less than 1 minute read

// load java.util.Scanner import java.util.Scanner;

class Main { public static void main (String[] args) { Scanner scanner = new Scanner(System.in);

 System.out.print("Name: ");

 // define the variable name, receive the string from the console and substitute
 String name = scanner.next();

 // Please be output as "Hello ◯◯-san"
 System.out.println ( "Hello" + name + "Mr.");    } } // receive a string from the console 

Tags:

Updated: