概念
代码
package lesson.l10_oop;/*** Illustration** @author DengQing* @version 1.0* @datetime 2022/7/1 14:31* @function 方法重载*/
public class Load {public static void main(String[] args) {Load load = new Load();load.mOL(4);load.mOL(4, 5);load.mOL("ff");System.out.println(load.max(1, 3));System.out.println(load.max(-1, -3));System.out.println(load.max(0, 10, -10));}// 运算public void mOL(int a) {System.out.println(Math.sqrt(a));}public void mOL(int a, int b) {System.out.println(a * b);}public void mOL(String str) {System.out.println(str);}// 最大值public int max(int a, int b) {return Math.max(a, b);}public double max(double a, double b) {return Math.max(a, b);}public double max(double a, double b, double c) {double m = Math.max(a, b);return Math.max(m, c);}
}