zuoye

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;
}

}
这个代码写了方法的重载,一个是double类型一个是int类型,重载是参数类型不同以及个数不同也可以造成重载。
Java提供了一个BigInteger类,支持大整数的加减乘除运算。

posted @ 2025-10-08 15:12  黎昀  阅读(6)  评论(0)    收藏  举报