在类中不能写一条语句比如你写的System.out.print("劳动工具");
要继承的话只能将其封装在一个方法中,这是OO的基本要求。

解决方案 »

  1.   

    呵呵,先看书先看书《Java语言和面向对象程序设计》清华大学 20多块先看这本书吧
      

  2.   

    1:简单说来,继承等于是创建了一个新类,这个新类包含父类的所有成员(private被隐藏),并且复制了父类的接口。当然还可包含父类所不具备的方法等。
    2:为什么要继承,省写N多代码啊!代码重用,节省开支。
    3:不能继承的有最后的类和方法,即关键字final了的
      

  3.   

    比如父类superclass中有一个方法,supermethod(){System.out.print("生物");  };
    那么在子类中就可以调用这个方法,只有一个语句是不可以的。
    thinking in java,
    特别好的一本书,如果你要英文的话,网上哪里都有,如果中文,只有第一版,翻译得很烂,建议你看英文。
      

  4.   

    初学者看Thinking in java似乎不大恰当
    他似乎连面向对象都不清楚
    看JAVA思想难度高了点
    看看《Java 核心技术》第一卷:基础知识吧
    很简单很详细的说
      

  5.   

    呵呵。
    也是。那先看《Java语言和面向对象程序设计》
    王克宏编写的好像。
      

  6.   

    java中可以说只有类,对象,可以继承类,类中只有属性和方法..不是一条语句..
      

  7.   

    The members of a class type are all of the following:Members inherited from its direct superclass (§8.1.3), except in class Object, which has no direct superclass 
    Members inherited from any direct superinterfaces (§8.1.4) 
    Members declared in the body of the class (§8.1.5) 
    Members of a class that are declared private are not inherited by subclasses of that class. Only members of a class that are declared protected or public are inherited by subclasses declared in a package other than the one in which the class is declared.
    Constructors, static initializers, and instance initializers are not members and therefore are not inherited.
      

  8.   

    继承 只能继承类的属性和方法 然而 在主函数里面的只不过是对类进行的操作并不能够继承  假如这个程序这样写的话就可以继承了
    public class meclass{                                                               
     public void out(){                                           
        System.out.print("生物");                                                       
     }
    }        
    class human extends meclass                                       

                                                                      
    }                                                                   在这里的human不需要任何代码 就可以使用在meclass里面定义的方法        
    比如 
    human dd = new human();
    dd.out();
      

  9.   

    meclass里,什么方法都没有,没的继承,System.out.print()是lang里的方法,
    不是meclass的
      

  10.   

    楼上各位所说的不无道理,java是面向对象的,所以在学习前一定要高清楚什么是面向对象,什么是对象什么又是实例;
    记住:
    类是对象的定义,对象是类的实例,
    希望我的回复对你有所帮助。