方法重载(over load):方法名相同,参数列表不同,返回类型无关
package com.tanlei.newer; public class OverLoadDemo { public static void main(String[] args) { Printer printer=new Printer(1000); printer.print("hello"); printer.print(12); printer.print("hello", 12); } } class Printer{ private String bread="tanlei"; private double price; public Printer(double price) { this.price = price; } public Printer(String bread, double price) { this.bread = bread; this.price = price; } public void print(String content) { System.out.println("字符串"+content); } public void print(int content) { System.out.println("整型"+content); } public void print(String str,int content) { System.out.println(str+"--"+content); } }