





打开冰箱 储存进冰箱 关冰箱 都是一种过程
冰箱 为对象
对象是面向过程
< http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+w+a21LbUz/MgPC9wPgo8cD4tuabE3Ci5/bPMKSAtICAKttTP8yAgLQq21M/zICAtCrmmxNyjqLn9s8yjqTwvcD4KPHA+ICAgICDMzceuICAgICAgLda4u9PV3wotIMq10NDV3wotIMq10NDV37XEo6jE3MGmo6m5psTcPC9wPgo8cD7Su8fQvdO21M/zPC9wPgo8cD4gPC9wPgo8cD48aW1nIHNyYz0="https://www.cppentry.com/upload_files/article/76/1_krgxm__.jpg" alt="\">
public class CarDemo {
public static void main(String[] args) {
Car car = new Car();
car.color = "黑色";
car.run();
}
}
class Car { String color = "red"; //成员变量 主函数不在本内中访问其他类变量不需要加static
void run(){
System.out.print("我开跑咯: " + color);
}
}