The overload of the java method

establishes the same method in the phone,

package com.zzxt.java.mtexs;

Public class Phone {
String color;
Float screenSize;

Public void telphone(String phoneNo) {


}

Public void text(String phoneNo,String msg) {
System.out.println("=============>Send SMS");
}

Public void text(String phoneNo, Picture pic) {
System.out.println("=============>Send MMS");


}

Public void text(String phoneNo, String voice, Picture pic) {
System.out.println("=============>Send Mixed Information");


}



}

SMS, MMS, mixed information.

Create the picture class

package com.zzxt.java.mtexs;

public class Picture {

	String src;
	
	String width;
	
	String height;
	
	
	
	
	
	
}

主方法 below.

package com.zzxt.java.mtexs;

Public class Main {
Public static void main(String[] args) {
Phone phone = new Phone();
Phone.text("1455155", "terminate the transaction, there is a ghost");

Picture img = new Picture();

Phone.text("1455155", img);

Phone.text("1455155", "terminating the transaction, having a ghost", img);


}




}

Run Results

可知: The method names are the same, and the parameter list is different.