Object oriented
Process-oriented representative is mainly C language, object-oriented is relative to the process, Java is the object-oriented programming language, the process is through the function embodiment, the process is mainly functional behavior.
In the case of object-oriented, the function is encapsulated into an object, so object-oriented is process-oriented. Previously, it was primarily a process-oriented idea, and now it was loaded into the object, and if it was to be used, it would be called.
Object-oriented is the advance of the idea of entry, which is applicable to human thinking, simplifying complex things and changing our programmers from performers to conductors. transformed from previously oriented functionality (process-oriented) to object-oriented (encapsulated functionality).
****
The idea of object-oriented design
Changes in design ideas
For example: Student behavior
For structured programming: Get up, wash, eat, class, school
For object-oriented design, classes, methods in classes
Object-oriented features
- Packaging
- Inherited
- Polymorphic
Class-to-object relationships
A class is a description of a thing, with attributes and behaviors ;
Objects are entities that are created by this class, and are called through objects.
All things are objects, in which Java things are described in the form of classes, and classes are abstractions of concrete things.
Definition of Class
A class has properties and behaviors , which are collections that encapsulate data and data-related operations, and members of a class definition are member variables and member functions.
member variables and local variables
The member variable has a default initial value, the member variable is defined in the class, can be accessed by the entire class, the member variable is created with the object's creation, disappears as the object disappears, and is stored in heap memory.
A local variable is defined within a function, in which a local variable exists in the stack memory, runs as the method runs, ends in a stack, ends in scope, and has no default value.
Creating objects
Car c = new car (); Creating objects
Packaging
Encapsulation is the property and function of hidden objects, only public access is provided externally, encapsulation can improve security, reusability and so on.
constructor function
The constructor initializes the object with no specific return value, the return type, the function name and the class name.
this keyword
thisRepresents a reference to an object of this class.
Static
Use static the modified member variable as a static variable;
With a static decorated class, as a static class,
Used to modify the method, it is a static method.
static variables are all categorized, and static variables are called directly through the class without instantiating the object. static methods are also called directly with the class name. static methods can only manipulate static variables and cannot use instance variables.
Static loads with the load of the class and takes precedence over the existence of the object. Not available in static methods this super .
Conclusion
- This article mainly explains? Java Language Basics-Object-oriented fundamentals
- Below I will continue to
Java ,? Android In-depth explanation of other knowledge, and interested to continue to focus on
- A little gift to walk or like.
Section 25th: Fundamentals of the Java language-object-oriented Foundation