Java Programming 5
(i) Classes and objects:
Class
1. Properties
2. Behavior (method)
}
1) What is abstract:
From a specific point of view, from the existing things to extract the characteristics of concern, behavior, and thus form a new thinking process of things, is a kind of from the complex to the simple way of thinking;
(object: Real existence, entity);
2) describe human beings:
(A class is an abstraction of an object that is an entity generated by a class)
(1) Constructor:
Public Student () {
System.out.printLn ("This is the default constructor used");
}
* Features of the constructor:
1 "When creating an object, make a call after the new keyword;
2 "The constructor is also a method that does not require any return type compared to the normal method;
3 "The method name of the constructor is the same as the class name;
4 The constructor can also be used for object property initialization in addition to allocating memory for objects (using a parametric constructor);
5 if the parameter constructor is set in the class, the default constructor is not provided;
6 "The constructor can be overloaded;
* Constructor Function:
1) The created object is stationed into memory through the constructor (allocating space to the object in memory)
2) initialize attributes;
* * Constructor Purpose * *:
(Allocate storage time for objects when creating objects)
(ii) Packaging ideas:
Package {
Project name Structure
Enterprise Project Structure
Java Common package Name
}
Package Packages:
Naming rules:
1. The letter part is lowercase;
2. Enterprise (organization) domain name inverted. Team name. Name of the project;
Access modifiers:
Private no prote cted pubic
Inside the class ~ ~ ~ ~
Same Package ~ ~ ~
Sub-class ~ ~
Any Place ~
Java Programming 5