学习 Demo
码上行动
代码如下(示例):
package TestDemo;
/**
* 调用方法:对象名.方法名(实参列表)
*/
public class Test1 {
public static void main(String[] args) {
int max = max(10, 20); //调用max方法(实参)
System.out.println(max);
}
//比大小
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;
}
}