Classes, objects, and their behavior
1. Classes and objects
Class 1.1 is a reflection of an entity in the real world or the mind world in a computer that encapsulates data and the operations on that data, so a class is a collection of objects that have the same properties and behaviors.
The 1.2 class is an abstraction of an object, a template for an object, and an abstract data type.
1.3 Objects are real-world entities, objects are one by one corresponding to entities, which means that each of the real-world
An entity is an object, and it is a concrete concept. An object is an abstraction of an objective thing.
The 1.4 class is a collection of objects that are instances of the class, and objects are generated through new classname (forcing space in the heap class).
2. member variables and properties of a class
1. A property is a characteristic of an object, a behavior is an action that an object can make, each property in an object represents a member variable in a class, each behavior becomes a method in a class, and when the object is instantiated, two entities are actually created: a reference and an object, a reference to the memory address of the referenced object
2. Instantiating an Object
1. Syntax: Class name object (reference) name =new class name ();
2. Car car=new car (); Instantiation is actually the construction method of the calling class
3. Each class has a default non-parametric construction method.
4. In a method it is best not to use parameters unrelated to this method.
3. Accessing the properties and methods of an object
1. Access Object properties: Reference. member variable = assignment; (assigns a value based on the data type of the member variable)
2. Access method: Reference. Method name (to invoke a method in the class)
3. Object Instance Code
Classes, objects, and their behavior