JAVA问题总结之19--方法的重载(overload)
重载的概念
在同一个类中,允许存在一个以上的同名方法,只要它们的参数个数或者参数类型不同即可。double add(double x,double y){return x+y;}
public class PrintStream{ public static void print(int i) {……} public static void print(float f) {……} private static void print(String s) {……} public static void main(String[] args){ print(3); print(1.2f); print(“hello!”); } }
1.判 断: 与void show(int a,char b,double c){}构成重载的有: void show(int x,char y,double z){} //no int show(int a,double c,char b){} //yes c) void show(int a,double c,char b){} //yes d) boolean show(int c,char b){} //yes e) void show(double c){} //yes f) double show(int x,char y,double z){} //no g) void shows(){double c} //no