Seventh Day of Java learning

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.