定义一个computer类
public class computer {
public void runSoftWor(vidio vedio){
System.out.println("视频长度是 "+vedio.getLength());
}
public void runSoftWor(Voice voice){System.out.println("歌曲的名字是 "+voice.getTitle());
}public boolean runSoftWor(vidio vedio,long maxLength){System.out.println("视频长度是 "+vedio.getLength());return true;
}
}
定义一个vidio类
public class vidio {
private long length;public long getLength() {return length;
}public void setLength(long length) {this.length = length;
}
}
定义一个voice类
public class Voice {
private String title;public String getTitle() {return title;
}public void setTitle(String title) {this.title = title;
}
}
定义一个测试方法重载的类
public class test15 {
public static void main(String[] args) {computer com = new computer();vidio vedio = new vidio();vedio.setLength(999999L);com.runSoftWor(vedio);Voice voice = new Voice();voice.setTitle("我的中国心");com.runSoftWor(voice);
}
}