Hello, ladies and gentlemen, last time we talked about an example of Java synthesis exercise, this time we will talk about an example of Java object orientation. Stop gossiping and return to the truth. Let’s Talk Android!
C is a procedural programming language, while Java is an object oriented programming language. This time, we’re going to talk about object orientation. The core of object orientation is three aspects: encapsulation, inheritance and polymorphism.
1. The encapsulation
Encapsulation is the organization of interconnected content. From a program’s point of view, encapsulation is the grouping of variables and functions of various types. In fact, this content is developed bit by bit.
Broadly speaking, an array is a wrapper that encapsulates variables of the same type. Arrays were found to be a little inconvenient, so structs, which are more advanced encapsulation than arrays, can encapsulate variables of different types together. However, the technology is always developing, and the encapsulation of structure can not meet the technical requirements of people, so there are classes.
Classes are currently the highest level of encapsulation and can encapsulate variables and functions of various types. There is another special type of encapsulation in Java, which we’ll cover in more detail later, called interfaces.
2. The inheritance
To inherit means to get something from other places, for example, we often say: inherit the glorious tradition of the revolutionary predecessors. That is to say, we must learn from the fine style of work of our revolutionary predecessors and make it our own and continue to bring it into full play. From the point of view of the program, inheritance is mainly a subclass from the parent class where the variable or function of the parent class, inheritance should also follow certain inheritance rules, we will introduce you in detail when introducing inheritance.
3. The polymorphism
Polymorphism literally means multiple forms, and in programs it means multiple forms of objects. In the program, polymorphism is mainly reflected in the subclass object to the parent class object, through the parent class object to call the method of the subclass object. Polymorphism is an object – oriented content that is difficult to understand, and we will give a detailed introduction in the following chapter.
See officers, above 3 is face face the core content of the object. But beyond the core, there are a lot of details we need to understand. These details will be introduced in the next chapter.
Everybody see officer, about Java object oriented example let’s introduce here, want to know what other examples, and listen to the next time decomposition!