Demo28_方法的重载01

//方法的重载
package com.HuanXin.Fan_Fa_5;

public class Demo04_ {
public static void main(String[] args) {
//int chx = Chx(20, 20);
//System.out.println(chx);
double xx= xxx(10.1, 20.3);
System.out.println(xx);
}

/*public static int Chx(int a,int b){
int c=0;
if (a==b){
System.out.println("a==b");
return 249088;
}
if (a>b){
c=a;
}else {
c=b;
}return c;
}*/

public static double xxx(double A,double B){
double C=0;
if (A==B){
System.out.println("A==B");
return 1008611;
}
if (A>B){
C=A;//就把A的值赋给C
}else {
C=B;
}return C;
}
}
/*
若方法体相同,但是计算的数据类型不同,只需要把数据类型修改为目标类型即可
*/
posted @ 2022-10-16 00:02  陈焕新  阅读(27)  评论(0)    收藏  举报