Learning Diary (ii) Java features

Source: Internet
Author: User

The core of Java is object-oriented, relative to the process-oriented programming, in the whole Java programming is not enough to understand and use the situation I am afraid there is no way to understand the two concepts well.

In my initial understanding, writing a program, for example, to do one thing, the process-oriented thought might refer to what this step does, what to do next, until it is done, the steps are highlighted, and the object-oriented thought is what this man does, what the man does, until it is done together. Although the result is the completion of the matter, a focus is on the steps to be taken, and the other is who does what.

All object-oriented programming languages contain three principles or features and mechanisms, namely encapsulation, inheritance, and polymorphism.

Everything in Java is an object, a class is an object, an interface is an object, a property is an object, and a method is an object. And what objects are, objects are object, that is what we are talking about. What is something? It can be said that the universe is a thing, a person is a thing, a thing is also a thing, everything is the object, that is, everything else.

The simple understanding of encapsulation is to integrate some scattered but somewhat related things as a whole, or these things can be called objects. Like a car as a program, it has a lot of parts, such as plastic parts, hardware, etc., but we usually only talk about the steering wheel, tires, and the steering wheel is not the smallest individual, they are composed of smaller parts, the assembly of these parts of the steering wheel to achieve the control direction of the process is the package.

The concept of inheritance is similar to the inheritance that we often say in our lives, that is, subclasses get part of the parent class, but not all. For example, we can inherit a part of the father's genes and thus grow like a father, but also inherit the father's network of the property, but his brother can not be our brother, or will be different. One thing to note is that here is the parent class rather than the father, which is very different from the so-called father, Father is, Grandpa Also, Grandpa's Grandpa is.

As I understand it, polymorphic concepts often involve interfaces and implementations, meaning that an interface can have many different implementations. As can take a man to do an example, people have identity, and identity is an abstract thing, is a relative concept, for his friend, his identity is a friend, for his juniors, he is an elder, and for his colleagues, he is a colleague. This person is an interface, identity is an abstract method, other different people are different ways to achieve this excuse, the specific identity is the specific implementation state. The same person, different identities, that's polymorphic.

Since polymorphism is usually associated with interfaces, what is an interface? Interfaces can be thought of as special abstract classes, which are abstract classes in which all methods are abstract methods. It is important to note that abstract classes can have several forms, can have no abstract methods, can have some abstract methods, or they can all be abstract methods. But what exactly is an interface? For the moment, the USB interface, as we usually call it, is an interface, because it also has polymorphism, and when we use it to connect a mouse or keyboard, its function is a state, which is a state when we use it to connect data lines to transmit data.

Encapsulation, inheritance, polymorphism is originally a concept, the concept is defined by people, so the specific understanding of different people may not be the same, but in general it is so.

Learning Diary (ii) Java features

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.