有什么方法吗?
方法是程序中最小的执行单元。
公共 类 演示 {公共 静态 空隙 主要(字符串[]参数){ 系统.输出. println("第一个数字");系统.out.println("第二个数字“);}
}
两条输出语句必须一起执行,而不是只执行其中之一。
这种方式在实际开发中有什么好处?
public static void 方法名称 () {//方法体}
方法名称();
playGame();
注意
公共 类 方法演示 {公共 静态 空隙 主要(字符串[]参数){ 玩游戏(); }公共 静态 void playGame (){系统。 out.println("选择角色");系统.出.println ("准备开始");系统.out .println( “行”);系统.出.println( “崩溃”);系统。 系统.输出 ... .println("GG") ;}
}