<> object

. Three characteristics of object-oriented : Encapsulation , Inheritance and polymorphism , There is no inheritance and polymorphism in process oriented , And process oriented encapsulation is just encapsulation function , Object oriented can encapsulate data and functions . So the object-oriented advantage is more obvious .

<> Summary of object oriented and process oriented

1, It's all a problem-solving way of thinking , It's all code organization .

2, Process oriented can be used to solve simple problems

3, Solving complex problems : Macro use of object-oriented grasp , Micro processing is still process oriented .

<> What is an object

1. Object is also a data structure ( Management mode of data ), Put data and data behavior together .

2. In memory , Object is a block of memory , Relevant data set stored

3. The essence of an object is a way of organizing data

<> Classes and objects

1. Objects are concrete things ; A class is an abstraction of an object ;

2. Class can be regarded as a template for a class of objects , Object can be regarded as a concrete instance of this class .

3. Class is an abstract concept used to describe objects of the same type , Class defines the common properties that this class of objects should have , method .

Let's define a student class SxtStu:
public class SxtStu { // attribute ( Member variable ) int id; String sname; int age; // method void study
(){ System.out.println(" I am learning !"); } // Construction method SxtStu(){ } }
<> attribute

Property is used to define the data or static characteristics contained in this class or its objects . Property scope is the whole class , Member variables can be initialized when they are defined , If it is not initialized ,Java Initialize it with the default value .

<> method

Method is used to define the behavior characteristics and function implementation of this class or its instance . Methods are abstractions of behavior characteristics of classes and objects . Methods are very similar to functions in process oriented . Process oriented , Function is the most basic unit , The whole program consists of function calls . Object oriented , The basic unit of the whole program is the class , Methods are subordinate to classes and objects .

practice :
class Computer{ String brand;// brand } public class est { int id; String name; int
age; Computer comp; void study() { System.out.println(" I am learning ! Computers used ," + comp.
brand); } est() { } public static void main(String[] args) { est stu1 = new est(
); stu1.name = " Woods "; Computer comp1 = new Computer(); comp1.brand = "lenovo";
stu1.comp = comp1; stu1.study(); } }
Running screenshot :

Technology
©2019-2020 Toolsou All rights reserved,
( Essence )2020 year 6 month 26 day C# Class library Exception handling help class Vue Transfer parameters and receiving of page Jump CCTV :Tiktok A lawsuit shows the attitude and determination of safeguarding rights Dijkstra Algorithmic Python realization - Shortest path problem python read , write in txt Text content Result Encapsulation of return result information Centos7 lower mysql8.0 To install and change the initial password ;element ui Drop down box search function ( Essence )2020 year 7 month 30 day Wechat applet Use of modules Vue + Element-ui Drop down box for el-select Get extra parameters