Here you can find the source of promptRequired(String message)
Parameter | Description |
---|---|
message | a parameter |
public static String promptRequired(String message)
//package com.java2s; //License from project: Open Source License import java.util.Scanner; public class Main { private static Scanner in = new Scanner(System.in); /**/*from w w w .j a va 2 s. com*/ * Prompt user for input, requiring non-empty input. * @param message * @return a line of user's input */ public static String promptRequired(String message) { System.out.print(message + ": "); String line = in.nextLine().trim(); return line.equals("") ? promptRequired(message) : line; } }