代码如下: 
//Note.java 
package c07.music; public class Note{ 
private String noteName; 
private Note(String noteName){ 
this.noteName=noteName; 

public String toString(){return noteName;} public static final Note 
MIDDLE_C =new Note("Middle_c"), 
C_SHARP=new Note("C_Sharp"), 
B_FLAT=new Note("B_Flat"); 

//编译成功 //Instrument.java 
package c07.music; public class Instrument { 
public void play() {} 
public void tune(Instrument i) { 
//i.play(Note i); 
i.play(); 


//编译成功 
//Wind.java 
package c07.music; public class Wind extends Instrument{ 
public void play(Note n){ 
System.out.println("Wind.play()"+n); 


//编译成功 package c07.music; 
//Music.java 
public class Music{ 
public static void tune(Instrument i){ 
i.play(Note.MIDDLE_C); 

public static void main(String[] args){ 
Wind flute=new Wind(); 
tune(flute); 


//编译信息:play() in c07.music.Instrument cannot be applied to (c07.music.Note) i.play(Note.MIDDLE_C); 
1 error

解决方案 »

  1.   

    你定义了Instrument.play(Note node)方法吗?
      

  2.   

    public void play() {},里面没有参数,你调用i.play(Note.MIDDLE_C); 肯定会报错!
      

  3.   

    public static void tune(Instrument i){
            i.play(Note.MIDDLE_C);
        }
    改为
        public static void tune(Wind i){
            i.play(Note.MIDDLE_C);
        }
    wind继承了Instrument,在wind里才有i.play(Note.MIDDLE_C);方法,而Instrument里没有