提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
在Java中使用重载方法
public class Main { public void print(String str) { System.out.println("print(String): " + str); }//来自 N o w J a v a . c o m public void print(Object obj) { System.out.println("print(Object): " + obj); } public void print(Double num) { System.out.println("print(Double): " + num); } public static void main(String[] args) { Main pt = new Main(); Object[] list = new Object[]{"Hello",