package entity;
/**比较两个数大小的方法
* @author Administrator
*
*/
public class Demo2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//前面类型是int就调用int方法 前面类型是double就调用double方法
int max = max(10,20);
System.out.println(max);
}
//方法重载 把方法中的int 换成double 就完成方法的重载
// public static void main(String[] args) {
// // TODO Auto-generated method stub
// double max = max(10.0,20.0);
// System.out.println(max);
// }
public static double max (double a,double b) {
double result = 0;
if(a==b) {
System.out.println("a==b");
return 0;
}
if(a>b) {
result=a;
}else {
result=b;
}
return result;
}
public static int max (int a,int b) {
int result = 0;
if(a==b) {
System.out.println("a==b");
return 0;
}
if(a>b) {
result=a;
}else {
result=b;
}
return result;
}
}