class
Is a collection of abstract concepts, the product is represented by a common, among the class definition is a state and behavior.
The concept of class
Class is composed of Java basic elements of a program, it encapsulates the properties and methods.
Class is a template for creating an object, each object has its own property values.
The feature class: encapsulation, inheritance, polymorphism.
Objects
An object is a representation of personality, represent a separate entity, each object has its own independent properties, relying on property to distinguish between different objects.
The relationship between classes and objects
Class is a template object, the object is an instance of the class. Class is only available through the object, we must first create a class, and then create a class. Class can not be directly used, the object can be used directly.
Create Object
1. declare an object reference variable
The following format: class name objects watches; example: Point P1, P2;
2 . Create objects.
Format reference variable name = new constructor ()
You can also create an object at the same time declare a reference variable
Format is as follows: A class name reference variable name = new constructor () ;
2. Access by reference variable object members
Reference variable names . Attributes
Reference the variable name . Method name (argument list)
Members of the class object access method
By object name and member operator
Pointer to an object by
By object reference variables
Object Initialization
When you create an object, the object attribute members to give the allocated memory space, while initialized. If the initial value is not specified when defining attribute member, the system automatically assigns the initial value. You can specify the initial value when defining attribute members.
Variable scope
Scoped variables, also known as the effective range of variables, it is a regional program variables can be accessed in its scope. scope also determines when the system variables to create and clear the memory.
data collection
Note: Note decimal point, the cast may cause data loss
class
Is a collection of abstract concepts, the product is represented by a common, among the class definition is a state and behavior.
The concept of class
Class is composed of Java basic elements of a program, it encapsulates the properties and methods.
Class is a template for creating an object, each object has its own property values.
The feature class: encapsulation, inheritance, polymorphism.
Objects
An object is a representation of personality, represent a separate entity, each object has its own independent properties, relying on property to distinguish between different objects.
The relationship between classes and objects
Class is a template object, the object is an instance of the class. Class is only available through the object, we must first create a class, and then create a class. Class can not be directly used, the object can be used directly.
Create Object
1. declare an object reference variable
The following format: class name objects watches; example: Point P1, P2;
2 . Create objects.
Format reference variable name = new constructor ()
You can also create an object at the same time declare a reference variable
Format is as follows: A class name reference variable name = new constructor () ;
2. Access by reference variable object members
Reference variable names . Attributes
Reference the variable name . Method name (argument list)
Members of the class object access method
By object name and member operator
Pointer to an object by
By object reference variables
Object Initialization
When you create an object, the object attribute members to give the allocated memory space, while initialized. If the initial value is not specified when defining attribute member, the system automatically assigns the initial value. You can specify the initial value when defining attribute members.
Variable scope
Scoped variables, also known as the effective range of variables, it is a regional program variables can be accessed in its scope. scope also determines when the system variables to create and clear the memory.