Object-Oriented Programming (2) -- objects and classes, object-oriented programming objects
Concepts of objects and Classes
- Object: a specific thing;
- Class: abstract)
First, there are specific objects, then abstract the image parts of each object, and summarize the classes. Then, we can review other objects through the classes.
Summary of objects and Classes
Relationship between objects and classes: special to general, specific to abstract
- Class, which is called Class;
- Objects are called objects and instances. In the future, we will talk about objects of a class and instances of an Object.
- Class, can be seen as a Class Object template, the object can be seen as a specific instance of this class.
- A class is an abstract concept used to describe objects of the same type. The class defines the static and dynamic attributes of this class of objects.
- Objects are the core of Java programs. in Java programs, "Everything is an object ".
Reference)
In Java, variable types except basic types are called reference types.
Ps: describes the following data types:
Basic data types (8 types ):
Numeric type: INTEGER (byte, short, int, long) floating point type (float, double)
Character Type: char
Boolean: boolean
Reference Type:
Class: class
Interface: interface
Array
Objects in Java areReferenceTo operate on it.
Class has attributes and method composition class attributes
- Attribute field, or member variable
- Attribute is used to define the data or static attributes contained in this class or this class object.
- The attribute applies to the entire class body.
- You can initialize a member variable when defining it. If it is not initialized,Java uses the default value for initialization.. (Value: 0, 0.0; char: \ u0000; boolean: false; all reference types: null)
Attribute Definition Format:
Class Method
- In object-oriented, the basic unit of the entire program is class, and methods are subordinate to class
Method Definition Format
In Java, the method parameters are passed as follows:Value Transfer!
Variable Scope