Java Object Oriented 01

Process-oriented thinking
1. The steps are clear and simple, what to do in the first step, and what to do in the second step...
2. Facing the process, it is suitable to deal with some simpler problems.
Facing the object thinking
. Which categories are needed to solve the problem, and then think about these categories individually. Finally, the process-oriented thinking is carried out on the details of a certain category.
2. Object-oriented is suitable for dealing with complex problems, suitable for dealing with problems that require multi-person collaboration.
What is object
- oriented 1. Object-Oriented Programming (OOP)
2. The essence of object-oriented programming is to organize code in a class , Organize (encapsulate) data with objects
**Core idea: **
Three abstract features,
encapsulation,
inheritance
, polymorphic
classes and objects:
1. From an epistemological perspective, there are classes behind existing objects. Objects are concrete things. Class is abstract, it is an abstraction of objects.
2. From the perspective of code operation, there are objects behind existing classes. Classes are templates for objects

Recall method call

Static method

Code example:
Insert picture description here

Sample output:

Insert picture description here

Non-static method

Code example:
Insert picture description here

Sample output
Insert picture description here
Note (static is loaded with the class)

Pass by reference

Code example:

package com.OOP;

public class Demo03 {
    public static void main(String[] args) {
        Numbers numbers = new Numbers();
        System.out.println(numbers.a);//未定义值,默认为0
        Demo03.change(numbers);
        System.out.println(numbers.a);
    }
    public static void change(Numbers numbers){
        //number是一个对象:指向的--->Numbers numbers = new Numbers();这是一个具体的数字,可以改变属性
        numbers.a=10;
    }
}
class Numbers{
    int a;
}

Output example
Insert picture description here
(pointer that feels similar to C)

Guess you like

Origin blog.csdn.net/qq_51224492/article/details/113702734