package java_package; public class java_class7 { public static void main(String[] args) { hello(); int rs=c(10,10); System.out.println(rs); System.out.println( c(18, 17) ); } /** * 无参数无返回值方法 * public static void hello(){ * for (int i = 1; i <3 ; i++) { * System.out.println("helloworld"); * } * } */ /** * 有参数无返回值 * public static void hello(int n){ * for (int i = 1; i <n ; i++) { * System.out.println("helloworld"); * } * } */ public static void hello(){ for (int i = 0; i <3 ; i++) { System.out.println("helloworld"); } } public static int c(int a,int b){ //有参数有返回值 int c=a+b; return c; } }
java基础知识7(参数和返回值)
最新推荐文章于 2024-10-01 09:29:45 发布