you are welcome to join the Big data (HADOOP, SPARK, data Mining) Learning Exchange Group, to share big data materials, communicate with each other as the main qq:550174771Overloading of methods
You can have multiple methods in a class that share the same name, as long as they have different parameters
parameter types differ in number of parameters
Package com.java2006;
Public class computer {
//Here static is the function of the method, in test can directly class name. Method access is not accessible by means of the new object
public static   int sum ( int a, int b) {
return a+b;
}
public static   double sum ( double a, double b) {
return a+b;
}
This defines a non-static method that is accessed through the new object
public int add ( int a, int b, int c) {
return A+b+c;
}
}
Define a test class
Package com.java2006;
Public class test1 {
Public static void main (string[] args) {
Here
int sum =computer. sum (1, 3);
System. out . Print (sum);
Double sum1=computer. sum (3.1, 5.4);
System. out . Print (SUM1);
Computer sum2= New computer ();
int aa=sum2.add (1, 2, 3);
System. out . Print (the value of "AA "+aa);
}
}
This article is from the "struggling small snail" blog, please be sure to keep this source http://sparkkang.blog.51cto.com/11242173/1755499
Summary of J2SE Foundation-construction method