First of all,the programming ideas of the object-oriented programming and process-oriented programming
a.The process-oriented programming
1.According to the sequential order of functions to realize corresponding methods
2.Carry out the functions in order
b.The object-oriented programming
1.Analyze the entity of the whole project,extract their common attributes as a Class to encapsulate their attributes and methods.
2.The function will be carried out when invoked.(触发式 flip-over type)
The definition of a Class
Each initial should be uppercase in a class.
1. The Qualifier
a.
public: The qualifier of the class,which means this class can be externally accessible.
In Android Developer(Android Studio),a public class when is used,its name should be consistent with its defined name (file suffix is '.java' when a class is defined).
b.
private:A class that can't be externally accessible.
2.The Keyword - class
- Class is used to define a class
for example: public class Student{}
and then, the "Student" is the name of this class. - We can establish class as long as we want.But for a public class,it should be defined at the very start and, in a same java.file,there only can exist one public class.
But when there exist mutiple classes,we still can use public,private to limit them.
-the Inner class
The establishment of an Object
The object is the instantiation(实例化) of a class.
-
new
When a class is defined
public class Student(){
}
Then we can use "new" to establish the object.
Student xw = new Student();
But the consturctor(构造方法)are unaltered,it's the same to the class itself.
It can be comprehended that we use new to invoke the constructor of this class,and its structure(结构)is " 'class name' + ()".
-
The same to the pointer
For a defined object:
Student xw = new Student();
Student xl = xw;
both of xl and xw point to the same memory area existing in the heap(堆).
So they own the same functions.
So we can find that it is same to pointer.