Let's talk about some of my understanding and summary of object-oriented.
1. What is object-oriented? My own understanding is a kind of programming idea, emphasizing object, is a thinking mode of thinking problem. In learning object-oriented, we should establish our own object-oriented thinking mode.
(1), the first whole, after the local.
(2), first abstract, after the specific.
(3), what can do, and how to do.
2. What are the characteristics of object-oriented?
(1), object-oriented is actually a kind of common thought, accord with people's reference.
(2), the appearance of object-oriented, the complexity of the problem is simplified.
(3), the appearance of object-oriented, so that once in the process of the executor, into the object of the leader.
3, how to learn the object-oriented.
Mastering an object-oriented language grammar, familiar with object-oriented design principles, familiar with object-oriented design patterns.
4. Classes and objects
What is a class?
Classes: Categories, categories, classification we can distinguish different kinds of things, so a class is a set of things that have the same attributes (attributes) and behaviors (methods).
The relationship of a class to an object?
(1), the class represents a common product, is a comprehensive feature, and the object, is a product of personality, is an individual characteristics.
(2), the class has the attribute and the method composition, the attribute is equal to an individual's characteristic, the method is equal to one kind of behavior.
(3), a class is a description of something, and an object is an instance of that kind of thing.
Summary: The purpose of the description class is to describe the properties and functions common to a kind of things, which are characterized by variables and function through methods.
5. Class and object Definition format:
Class: Defining a class is actually defining a member of a class: the member variable () property and the member function (the behavior method).
Class Name {
property name;
Return value type method name () {}
}
Object: An individual of the real existence of such a thing, a class that wants to actually operate, must depend on the object.
Format:
Class Name Object name =new class name ();
If you want to access methods and properties in the class, follow the syntax below.
Access properties in a class: Object. Properties;
Call a method in a class: Object. Method ();
6. New keyword
(1), you can create an object
(2), you can instantiate an object
(3), can apply for memory space
Create an instance of car in your computer by using the new
1 car c=new Car (); //c is a reference variable of a class type, which points to the object of the class 2 c.num=// Property 3 c.color="Red/ ////Behavior call
7, the difference between the member variable and the local variable
(1), the member variable is defined in the class, and the entire class is accessible. The local variable is defined in the function, statement, and local code block, only valid in the owning region.
(2), member variables exist in the object of the heap memory. Local variables exist in the method of stack memory.
(3), member variables exist as the object is created and disappear as the object disappears. Local variables exist with the execution of the owning region and are released as they end.
(4), the member variable has the default initialization value, the local variable does not have the default initialization value.
8. Anonymous object: An object without a name
New Car (); An anonymous object is actually a shorthand program for defining objects.
What are the restrictions?
The format can be simplified when the object makes only one call to the method.
New Car (). num=5;
Object Oriented Java learning Note (3) (1)