JAVA-oriented OOP and oop

Source: Internet
Author: User

JAVA-oriented OOP and oop

I haven't posted a blog for a while. I am very tired every time, but I feel very full ..

Recently, I have found that many beginners are familiar with object-oriented programming and are not very clear about how classes are converted into objects. Today I am going to talk about my understanding here, let's study it together...

To understand object-oriented, first, we need to understand what is a class, what is an object, and then talk about object-oriented, and then OOP, right:

Let's talk about objects first:

The object is defined to be composed of specific things with properties and methods;

So what does this sentence mean?

That is to say, the object must actually exist. For example, your girlfriend actually exists beside you. You can see that, you can also find it (I don't know if I can touch it). She has her own characteristics that allow you to tell which of the many women is your girlfriend, what are her static features? For example, name, appearance, and height. Body, bust, etc. These are her attributes. In programming, what are the attributes? That's the data type we have learned, such as int and String. Then your girlfriend has some dynamic features besides foreign trade, right? For example, if she likes to eat bananas, she's like to swing and walk, right? So these are what she is used to, and the operations she performs are our methods. In programming, the methods are our functions, and the main function is a special method. So the concept of our object is coming out. Do you understand it?

So what is a class?

Definition: classes are abstracted from objects with the same attributes and methods.

So how can this sentence be understood? For example, how do we distinguish a dog from a dog? First of all, are they all bark? Are all four errands running? Are there similarities in appearance? So we sum up their similarities to form the dog family class, which is abstract;

So what is class encapsulation? It is to put the attributes and methods in one, and then hide the details.

What about object-oriented programming? It is to program in the smallest unit of class. When using this class, we don't need to consider how this class comes from. We only need to know what this class is doing, do you understand this?

Next study object-oriented 2:

Relationship between classes and objects

Class Object Name = new object (); how to convert

 

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.