01-Object-oriented (overview)
Object-oriented-refrigerator. Open, refrigerator, storage, refrigerator. Close;
02-Object-oriented (example)
Use and command--objects, do not need to pay attention to the process, only focus on the results;
Everything is object, everything is Object--from "Thinking in Java"
03-Object-Oriented (class-to-Object relationships). avi
/* people open the door: The method of noun refinement. person { Open door (door) { door. open (); }} door {* /
View Code
PackageMyfirstcode;//Object-oriented: Three features, encapsulation, inheritance, polymorphism//later development: is actually looking for objects to use. If there is no object, an object is created. //find objects, build objects, use objects, and maintain the relationships of objects. /** Class and object relationships. * Real-Life objects: Zhang San, John Doe. * Want to describe: Extract the common content in the object. The specific abstract class is: A description of real-life transactions. * Object: This is the kind of thing, the real entity. *///requirements: Describe the car (color, number of tires). Describing things is actually describing the properties and behavior of things. //A property corresponds to a function (method) in a class that corresponds to a variable in a class. //In fact, defining a class is describing things, that is, defining properties and behaviors. Properties and behaviors become members of a class (member variables and member methods). classcar{//Description ColorString color = "Red"; //describe the number of tires intnum = 4; //run the behavior. voidrun () {System.out.println (color+".." +num); }} Public classcardemo{ Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//production of automobiles. This is done in Java with the new operator. //is actually generating an entity in heap memory. Car C =NewCar (); //Requirement: Change the color of the existing car to blue. Directs the object to be used. The command mode in Java is: Object. Object memberC.color = "Blue"; C.run (); Car C1=NewCar (); C1.run (); }}
View Code
04-Object-oriented (member variables and local variables). avi
05-Object-oriented (application of anonymous objects). avi
06-Object-oriented (encapsulation overview). avi
07-Object-oriented (encapsulated private). avi
08-Object-oriented (constructor). avi
09-Object-oriented (construction code block). avi
10-Object-oriented (this keyword). avi
11-Object-oriented (app for this keyword). avi
12-Object-oriented (the This keyword is called between constructors). avi
Java Learning day05