【发布时间】:2014-04-16 03:38:37
【问题描述】:
例如,程序会要求用户输入,然后它会产生一些输出然后它就完成了,但是如果用户想通过 main 方法,我怎样才能让它再次循环呢?
这是我的代码:
public static void main(String[] args) {
Scanner sc = new Scanner(System. in );
System.out.print("Please enter the first name of the person you would love to know about : ");
String hisName = sc.next();
printSomeInfoAbout(hisName);
}
如果用户决定再次运行,我将如何让它再次运行?
【问题讨论】:
-
你可以考虑看看Control Flow Statements
-
在 oracle 网站上做一个完整的(免费)编程教程。将在今天和未来几个月内提供帮助docs.oracle.com/javase/tutorial 滚动到下面的 Trails Covering the Basics - 'Getting Started' 等