Is it possible to print text that can be edited by the user (for console programs)?

前端 未结 3 1311
小蘑菇
小蘑菇 2020-12-21 06:39

Say I allow the user to edit something, like the phone number in an Address Book (actually, that\'s exactly what I\'m doing). Is there something that I can add to println th

3条回答
  •  清酒与你
    2020-12-21 07:27

    If you opened a window that looks like the console window, and could react to keypress events, then you could do what you are asking, but, otherwise, if you are just running a program, the program will have ceased executing and returned control to your console, so it can't do anything else.

    But, if you use a scriptable version of java you could write your own shell, and then you could do what you are asking, as the shell would not cease executing.

    But, that will probably be beyond your course.

提交回复
热议问题