- 一个类中有多个相同名字的方法,但参数不一样
-
/** * 测试重载 */ public class TestOverLoad { public static int add() { return 0; } public static int add(int a,int b) { return a+b; } public static void main(String[] args) { int c1 = add(); System.out.println(c1); int c2 = add(3,4); System.out.println(c2); } } 运行结果 0 7
方法重载11111
最新推荐文章于 2024-07-20 23:55:03 发布