方法
什么是方法
System.out.println()
package ff;
import com.sun.org.apache.xerces.internal.impl.dv.xs.AbstractDateTimeDV;
public class Dome1 {//main方法
public static void main(String[] args) {
}
public int add(int a,int b){
return a+b;
}
}
package ff;
public class Dome2 {
public static void main(String[] args) {
int max =max(10,20);
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;
}
}
package ff;
public class Dome3 {
public static void main(String[] args) {
int max =max(15,20,30);
System.out.println(max);
}
public static int max(int num1,int num2,int num3){
int recult =0;
if (num1==num2){
System.out.println("num1==num2");
return 0;
}else if (num2==num3){
System.out.println("num1==num2");
return 0;
}else if (num1==num3){
System.out.println("num1==num3");
return 0;
}else if (num1<num2){
recult = num2;
}else if (num1>num2){
recult = num1;
}else if (num2<num3){
recult = num3;
}else if (num1<num3){
recult = num3;
}return recult;
}
}