Here you can find the source of prompt(String message)
Parameter | Description |
---|---|
message | The message to show the user, verbatim, with no newline at the end |
public static String prompt(String message)
//package com.java2s; //License from project: Apache License import java.util.Scanner; public class Main { /**/*from w w w. j av a 2s .c o m*/ * Scanner instance **/ private static final Scanner scan = new Scanner(System.in); /** * Prompts the user with a given message and returns their response. * The given message is printed verbatim, with no newline, and one line of input is recorded and returned. * * @param message The message to show the user, verbatim, with no newline at the end * @return The user's response to the message. One line of recorded input */ public static String prompt(String message) { System.out.print(message + ": "); return scan.nextLine(); } }