//java 栈的概念: 存在函数执行的内存空间,函数执行完毕后就立马释放。 遵循先进后出的规则。
class FunctionDemo
{
/*函数的重载(overload)特点:
1、在同一个类中
2、同名函数
3、只要他的参数个数 or 者参数类型不同即可。
4、函数定义名字根据功能定义
5、函数的重载和返回值类型无关
6、java是严谨性语言,如果函数出现的调用不确定性,会编译失败。
7、函数的重载可以提高函数的复用性 */
public static void main(String[] args)
{
System.out.println("Hello World!");
}
public static int add(int a ,int b)
{
return a+b;
}
public static double add(double a,double b)
{
return a+b;
}
public static int add(int a,int b,int c)
{
return a+b+c;
}
}
// 函数重载提高函数的复用性
public static void main(String[] args) { printCFB(5); printCFB(); } //打印乘法表 public static void printCFB(int num) { for(int x =1;x<=num;x++) { for(int y=1;y<=x;y++) { System.out.print(x +"*" + y + "=" + x*y+ "\t"); } System.out.println(); } } //打印标准乘法表 9*9 //提高函数的复用性。 public static void printCFB() { printCFB(9); } }