# # #06.01_ Object Oriented (Overview of object-oriented thinking) (Learn)
* A: Overview of process-oriented thinking
* First Step
* Step Two
* B: An overview of object-oriented thinking
* Find objects (first step, second step)
* C: Example
* Buy Pancake fruit
* Washing clothes
* D: Object-oriented thinking features
* A: A thought that is more in line with our thought habits
* B: Complex things can be simplified
* C: Turn us from performer to conductor
* Character has been converted
* E: Object Oriented development
* is constantly creating objects, using objects, directing objects to do things.
* F: Object oriented design
* In fact, it is the relationship between managing and maintaining objects.
* G: Object-oriented features
* Package (encapsulation)
* Inheritance (Inheritance)
* Polymorphic (polymorphism)
# # #06.02_ Object-oriented (class and Object overview) (Master)
* A: What do we learn to program for?
* In order to describe our daily life in the language of learning
* B: How we describe real world things
* attribute is the descriptive information of the thing (the noun of the thing)
* Behavior is what the thing can do (verbs in things)
* The most basic unit in C:java is a class, and Java describes things in class as well.
* Member variables are properties of things
* Member method is the act of Things
* D: Defining a class is actually a member of the definition class (member variables and member methods)
* A: The member variable is the same as the previously defined variable, except that the position has changed. In the class, outside of the method.
* B: The member method is the same as the previously defined method, except that static is removed and the function of static is explained in detail later.
* E: Concepts of classes and objects
* A: Class: is a set of related properties and behaviors
* B: Object: Is the concrete embodiment of this kind of thing
* C: for example:
* Class Students
* An object specific to a student is an object
# # #06.03_ Object-oriented (definition of student Class) (master)
* A: Student Affairs
* B: Student class
* C: Case Demo
* Attributes: Name, age, gender
* Behavior: study, sleep
# # #06.04_ Object-oriented (definition of mobile phone Class) (master)
* Imitate student class and let students do it themselves
* Attribute: Brand Price
* Behavior: Call, Send Message (sendMessage) play games (PlayGame)
# # #06.05_ Object-oriented (use of Student Class) (master)
* A: File name problem
* Write two classes in a Java file: A basic class, a test class.
* Recommendation: The file name matches the test class name.
* B: How to use the object?
* Create objects and use
* Format: Class name Object name = new class name ();
* D: How do I use member variables?
* Object name. Variable Name
* E: How to use the Member method?
* Object name. Method Name (...)
# # #06.06_ Object-oriented (use of mobile phone Class) (master)
* A: Students do their own work
* Imitate student class and let students do it themselves
# # #06.07_ Object-oriented (memory graph of an object) (master)
* A: Drawing Demo
* One Object
# # #06.08_ Object-oriented (memory graph of two objects) (learn)
* A: Drawing Demo
* Two different objects
# # #06.09_ Object-oriented (three memory graphs referencing two objects) (learn)
* A: Drawing Demo
* Three references, two object references to the same address
# # #06.10_ Object-oriented (the difference between member variables and local variables) (master)
* A: Different positions in the class
* Member Variable: Outside of method in class
* Local Variables: In the method definition or on the method declaration
* B: The location in memory is different
* Member variable: In heap memory (member variable belongs to object, object into heap memory)
* Local variables: in stack memory (local variables belong to method, method into stack memory)
* C: Different life cycle
* Member variable: As the object is created, disappears as the object disappears
* Local Variables: As the method is called, it disappears as the call to the method is complete
* D: Different initialization values
* Member variable: has default initialization value
* Local Variables: There is no default initialization value, it must be defined, assigned, and then used.
* Precautions:
* The local variable name can be the same as the member variable name, when used in the method, using the nearest principle.
* Basic data type variables include which: Byte,short,int,long,float,double,boolean,char
* Reference data type variables include: arrays, classes, interfaces, enumerations
# # #06.11_ Object-oriented (how the formal parameter of a method is called when it is a class name) (Master)
* A: The parameter of the method is the class name public void print (Student s) {}//print (New Student ());
* If you see the form parameter of a method is a class type (reference type), what you need here is the object of that class.
# # #06.12_ Object-oriented (overview and application of Anonymous objects) (master)
* A: What is an anonymous object
* Object without a name
* B: Anonymous Object Application Scenario
* A: Call the method, just call it once.
* So what is the benefit of this anonymous invocation?
* Save Code
* Note: It is not appropriate to call multiple times. The anonymous object call is complete garbage. Can be reclaimed by the garbage collector.
* B: Anonymous objects can be passed as actual parameters
* C: Case Demo
* Anonymous Object Application Scenario
# # #06.13_ Object-oriented (overview of encapsulation) (master)
* A: Package Overview
* refers to the properties and implementation details of hidden objects and provides public access only externally.
* B: Package Benefits
* Hide implementation Details and provide public access
* Improved reusability of the code
* Improved security.
* C: Encapsulation principle
* Hide content that does not need to be provided externally.
* Hide properties and provide public methods for accessing them.
# # #06.14_ Object-oriented (overview and features of the Private keyword) (master)
* A: The question of the age of human assignment
* B:private keyword Features
* A: is a permission modifier
* B: Can modify member variables and member methods
* C: Members modified by them can only be accessed in this class
* C: Case Demo
* Package and private applications:
* A: Modify the member variable with private
* B: Provide the corresponding getxxx () and setxxx () methods
* Private is only a form of encapsulation, not that encapsulation is private
# # #06.15_ Object-oriented (overview and application of the This keyword) (master)
* A:This keyword Features
* Represents a reference to the current object
* B: Case Demo
* The application scenario of this
* Used to distinguish between member variables and local variable names
# # #06.16_ Object-oriented (mobile phone class Code and test) (master)
* A: Student Practice
* Please write the phone class as a standard class and then create the object test function.
Class Demo2_phone {
public static void Main (string[] args) {
Phone P1 = new phone ();
P1.setbrand ("Samsung");
P1.setprice (5288);
System.out.println (P1.getbrand () + "..." + p1.getprice ());
P1.call ();
P1.sendmessage ();
P1.playgame ();
}
}
/*
Mobile Phone class
Properties: Brand, Price
Behavior: Call, send SMS SendMessage, play games, PlayGame
*/
Class Phone {//java bean
Private String brand;//Brand
private int price;//Price
public void Setbrand (String brand) {//Set up branding
This.brand = brand;
}
Public String Getbrand () {//Get Brand
Return this.brand;//this. Can be omitted, you do not add the system will default to you add
}
public void Setprice (int prices) {//Set price
This.price = Price;
}
public int GetPrice () {//Get price
return price;
}
public void Call () {//Phone
SYSTEM.OUT.PRINTLN ("call");
}
public void SendMessage () {//Send SMS
SYSTEM.OUT.PRINTLN ("texting");
}
public void PlayGame () {//Play games
System.out.println ("Play the Game");
}
}
# # #06.17_DAY06 Summary
* Summarize today's knowledge points.
Java Foundation work6