在类中不能写一条语句比如你写的System.out.print("劳动工具");
要继承的话只能将其封装在一个方法中,这是OO的基本要求。
要继承的话只能将其封装在一个方法中,这是OO的基本要求。
解决方案 »
- 三角形输出问题
- 百鸡问题
- 关于数据查询某部分时间段数据问题?
- JAVA面试题解惑系列(十一)——这些运算符你是否还记得?
- 如何解决这个错误
- 如何导入类
- 请问如何用java编写一个类似于windowsxp中的3D圆形按钮,给例子者给分
- 如何用jdbc连接Access数据库(用可读写的模式)
- 我做一个有SWING组件的APPLET,放到主页上是运行正常,但用中文输入法则出现问题,别人的机器就没有问题,我们机器的差别就是IE的版本。!!!
- 小白求助:Certificate for <IP> doesn't match any of the subject alternative alternati
- Java 的入门级小师弟,请各位高手指点迷津.
- 我用200分求一个javamail做的邮件系统的原码,要求比较完善!
2:为什么要继承,省写N多代码啊!代码重用,节省开支。
3:不能继承的有最后的类和方法,即关键字final了的
那么在子类中就可以调用这个方法,只有一个语句是不可以的。
thinking in java,
特别好的一本书,如果你要英文的话,网上哪里都有,如果中文,只有第一版,翻译得很烂,建议你看英文。
他似乎连面向对象都不清楚
看JAVA思想难度高了点
看看《Java 核心技术》第一卷:基础知识吧
很简单很详细的说
也是。那先看《Java语言和面向对象程序设计》
王克宏编写的好像。
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.
public class meclass{
public void out(){
System.out.print("生物");
}
}
class human extends meclass
{
} 在这里的human不需要任何代码 就可以使用在meclass里面定义的方法
比如
human dd = new human();
dd.out();
不是meclass的
记住:
类是对象的定义,对象是类的实例,
希望我的回复对你有所帮助。