Make the console wait for a user input to close

后端 未结 8 982
遥遥无期
遥遥无期 2020-11-30 01:49

I have a console application that after performing its tasks, must give feedback to the user, such as \"operation completed\" or \"operation failed\" and the detailed error.

8条回答
  •  自闭症患者
    2020-11-30 02:10

    public static void main(String args[])
    {
        Scanner s = new Scanner(System.in);
    
        System.out.println("Press enter to continue.....");
    
        s.nextLine();   
    }
    

    This nextline is a pretty good option as it will help us run next line whenever the enter key is pressed.

提交回复
热议问题