Here you can find the source of waitForEnter()
public static void waitForEnter()
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.Scanner; public class Main { /**// w w w . j a v a 2s .c om * Calling this method waits until the user presses enter (scans standard input for next line), writing * a default message to standard output: "[Press enter to continue]". */ public static void waitForEnter() { waitForEnter("[Press enter to continue]"); } /** * Calling this method waits until the user presses enter (scans standard input for next line), writing * a given message to standard output. * * @param message message to write to standard output before waiting for enter */ public static void waitForEnter(String message) { Scanner in = new Scanner(System.in); System.out.print(message); in.nextLine(); } }