摘要: 1 一、//Java方法定义(函数) 2 public class MethodTest01 3 { 4 public static void main(String[] args) 5 { 6 System.out.println(sumInt(1,2));//本类内不需要加MethodTest0 阅读全文
posted @ 2020-11-18 22:40 ITKV 阅读(211) 评论(0) 推荐(0)
摘要: 1 //方法递归(Recursion)1-->2-->3-->4-->3-->2-->1 2 //求1+……+4的和 3 public class RecursionTest01 4 { 5 public static void main(String[] args) 6 { 7 System.ou 阅读全文
posted @ 2020-11-18 22:08 ITKV 阅读(704) 评论(0) 推荐(0)
摘要: 1 //方法重载(Overload);方法名一样,参数不同; 2 public class OverloadTest01 3 { 4 public static void main(String[] args) 5 { 6 System.out.println("Hello World!"); 7 阅读全文
posted @ 2020-11-18 21:55 ITKV 阅读(1663) 评论(0) 推荐(0)
摘要: 1 public class Test 2 { 3 public static void main(String[] args) 4 { 5 int a=1,b=2; 6 System.out.println("Hello World! "+a+b+" "(a+b));//+在输出中作为连接符号,如 阅读全文
posted @ 2020-11-18 21:53 ITKV 阅读(139) 评论(0) 推荐(0)
摘要: Java方法:a.包括定义方法:方法就是函数;①.定义方法名规则:首字母小写,开头不能为 "_/$/ /./132/等特殊符号"②.viod没有return,数据类型必须和返回值数据类型相同<public static int sumInt(int a,int b)>③.方法的参数和返回值:可分为四 阅读全文
posted @ 2020-11-18 21:38 ITKV 阅读(157) 评论(0) 推荐(0)