当前位置: 首页 > 工具软件 > OOOP > 使用案例 >

java面向对象oo

施刚毅
2023-12-01

1、对象都有自己的属性和方法
2、外部对象调用这些方法,可以向他请求并传入参数,等方法结束后,返回结果
3、对象就是一个变量
4、类就是类型,从万千对象中抽取共性
5、对象是类的具体实现
6、op面向过程
public class hello {
public static void main (String[] args) {
int a, b, c;
a = 1;
b = 2;
c = op(a, b);
System.out.println©;
}
public static int op(int m,int n){
return m+n;
}
}
op结构方法是主体

7、oo面向对象
public class hello {
int a;
public void set(int a){
this.a = a;
}
public int add(int b){
return this.a + b;
}
public static void main (String[] args) {
int b=5;
hello oo=new hello();
oo.set(10);
System.out.println(oo.add(b));
}
}
oo结构所以的方法都从属于某一个对象,对象可以调用自身的方法

oo的主要特点
1、识认性:从事物中辨别一个对象
2、类别性:把多种对象归结为一类
3、多态性:这些对象有一定的共性也有一定的不同性
4、继承性:子类继承父类所有的东西并使用

 类似资料: