public class Textplayer extends player{
String text;
public Textplayer(String text) {
this.text=text;
}
public void play() {
  System.out.println(text);
}
public static void main(String[] args) {
Textplayer player=new Textplayer("good morning");
player.loop(3);
}
}

解决方案 »

  1.   

    public class Textplayer extends player
    和Textplayer player=new Textplayer("good morning");
    之间是不是有问题?
    一个是继承自player类,而另一个player则是标志符
    我觉得好蹊跷,个人见解,不要笑话。
    谢谢!!!!
      

  2.   

    player.loop(3)估计是这个方法的问题,去看下基类的这个方法。 其他一些地方写的不好,但是看不出问题!例如:Textplayer player=new Textplayer("good morning");
      

  3.   

    我觉得是player.loop(3);的问题,因为你继承自player类,又创建一个player对象,
    我猜想你的Textplayer类里应该没有loop()这个方法,而player.loop(3)应该是要调用Textplayer里的loop()方法,是不是你只在player类里定义了这个方法,反正我觉得你最好避免这种重复混淆的命名.
      

  4.   

    你的代码少个player类,只有loop()函数在player类中的属性为static的时候才可以这么用。不过不知你player类中怎么写的。