方法简述 package method;public class Demo01 {//main 方法public static void main(String[] args) {//实际参数:实际调用传递给他的参数int sum = add (1,2);System.out.println(sum);//test();}//加法//形式参数,用来定义作用的public static int add(int a,int b){return a+b;}} 方法定义的格式 方法定义和调用 package method;public class Demo02 {public static void main(String[] args) {double max = max(10.0, 10.0);System.out.println(max);}//比大小public static double max(double num1, double num2) {int result = 0;if (num1==num2){System.out.println("num1==num2");return 0;}if (num1 > num2) {result = (int) num1;}else {result = (int) num2;}return result;//终止方法}//比大小public static int max(int num1, int num2) {int result = 0;if (num1==num2){System.out.println("num1==num2");return 0;}if (num1 > num2) {result = num1;}else {result = num2;}return result;//终止方法} }