ch08 - 类及对象.ppt

Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections, loops, methods, and arrays. However, these Java features are not sufficient for developing graphical user interfaces and large scale software systems. Suppose you want to develop a graphical user interface as shown below. How do you program it? 类的定义 对象 以现实世界中的一个对象为例,如某个人、可以说人具有许多属性(或状态),如姓名、身份证号、性别、身高和体重;人还具有各种行为,如说话、走路、思维和吃饭。在OOP的世界里,对象也具有许多属性和行为。使用面向对象的技术,就可以以某个人建立一个模型。 类的定义 类的定义 类的定义 Java中类定义的一般格式为: 修饰符 class 类名 [extends 父类名]{ 类型 成员变量1; 类型 成员变量2;

文档评论(0)

1亿VIP精品文档

相关文档