1, can understand the object-oriented thinking
Object-oriented is a process-oriented programming idea, emphasizing the object, which is called by the object to invoke the function. It is a more human-like programming idea that simplifies complex things and turns our roles from performers to conductors.
2, can clarify the relationship between class and object
A class is an abstraction of the basic characteristics of a related thing in an objective world. Objects are the concrete embodiment of such things. For example, a mobile phone is a class, and Iphone7 is an object.
3. Define Student class
public class student{
Member variables
String name;
int age;
Member Methods
public void Tell () {
SYSTEM.OUT.PRINTLN ("I call:" + name + ", this year" +age+ "years old.) ");
}
}
public static void main studentdemo{
Instantiating an Object
Student stu = null;
Stu = new Student;
Stu.name = "Laohu";
Stu.age = 28;
Stu.tell ();
}
4. Ability to create objects and use objects to access members in a class
Public student{
String name;
int age;
}
Public studentdemo{
public static void Main (string[] args) {
Student stu = new Student;
Stu.name = "Zhoa";
Stu.age = 30;
}
}
5. Ability to tell the difference between a member variable and a local variable
1) Different position: member variable in class, outside method; local variable in method.
2) different memory locations: member variables in the heap area; local variables in the stack area;
3) Initialization: local variables are initialized; Member variables have default values, no initialization required;
4) The life cycle is different: The local variable is generated with the invocation of the method, disappears with the call of the method, and the member variable is generated with the object, disappearing as the object disappears.
6. Be able to define a standard class with the thought of encapsulation--pojo
7, can say this can solve the problem
1) Represents a property in a class;
2) Call the constructor method in this class;
3) Represents the current object.
8. Ability to create objects using construction methods
Class student{
Public Student (String name, int.) {
if (age>0) {
THIS.name = name;
return name;
}else{
return 0;
}
if (name) {
}
THIS.name = name;
This.age = age;
System.out.println ("I Call:" +name+ ", this year" +age+ "years old. ")
}
}
public class studentdemo{
public static void Main (string[] args) {
Student stu = new Student ("Laohu", 30);
}
}
Seventh Day of Java learning