Method Overloading
declaring a method with same name but
different amount of arguments (parameters coming in); return type
always the same; used a lot in constructors
Example of Constructor Overloaded:
public class Info {
private int type;
public Info() {
type=79;
}
public
Info(int t) {
type=t;
}
}
Example of
Normal Method Overloaded:
public class Info {
private int type;
public int tryIt() {
return 1;
}
public
int tryIt(int t) {
int x= t + 1;
return (x);
}
}
|