提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
重载的方法声明。
public class Main /**时 代 J a v a 公 众 号**/ { // test overloaded square methods public static void main(String[] args) { System.out.printf("Square of integer 7 is %d%n", square(7)); System.out.printf("Square of double 7.5 is %f%n", square(7.5)); } // square method with int argument public static int square(int intValue) { System.out.printf("%nCalled square with int argument: %d%n", intValue); return intValue * intValue; } /**来自 时代Java公众号 - nowjava.com**/ // square method with double argument public static double square(double doubleValue