编程语言
首页 > 编程语言> > Java学习10.8(动手动脑)

Java学习10.8(动手动脑)

作者:互联网

1.请看以下代码,你发现了有什么特殊之处吗?

//MethodOverload.java
//Using overloaded methods

public class MethodOverload {

    public static void main(String[] args) 
    {
        System.out.println("The square of integer 7 is " + square(7));
        System.out.println("\nThe square of double 7.5 is " + square(7.5));
    }

    public static int square(int x) 
    {
        return x * x;
    }

    public static double square(double y) 
    {
        return y * y;
    }
}

 

 

标签:square,Java,int,10.8,动脑,System,static,double,public
来源: https://www.cnblogs.com/Lizhichengweidashen/p/13799101.html