Java Learning day05

Source: Internet
Author: User

01-Object-oriented (overview)

Object-oriented-refrigerator. Open, refrigerator, storage, refrigerator. Close;

02-Object-oriented (example)

Use and command--objects, do not need to pay attention to the process, only focus on the results;

Everything is object, everything is Object--from "Thinking in Java"

03-Object-Oriented (class-to-Object relationships). avi

/* people open the door: The method of noun refinement. person {    Open door (door)    {        door. open ();    }} door    {* /
View Code
 PackageMyfirstcode;//Object-oriented: Three features, encapsulation, inheritance, polymorphism//later development: is actually looking for objects to use. If there is no object, an object is created. //find objects, build objects, use objects, and maintain the relationships of objects. /** Class and object relationships. * Real-Life objects: Zhang San, John Doe. * Want to describe: Extract the common content in the object. The specific abstract class is: A description of real-life transactions. * Object: This is the kind of thing, the real entity. *///requirements: Describe the car (color, number of tires). Describing things is actually describing the properties and behavior of things. //A property corresponds to a function (method) in a class that corresponds to a variable in a class. //In fact, defining a class is describing things, that is, defining properties and behaviors. Properties and behaviors become members of a class (member variables and member methods). classcar{//Description ColorString color = "Red"; //describe the number of tires    intnum = 4; //run the behavior.     voidrun () {System.out.println (color+".." +num); }} Public classcardemo{ Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//production of automobiles.        This is done in Java with the new operator. //is actually generating an entity in heap memory. Car C =NewCar (); //Requirement: Change the color of the existing car to blue. Directs the object to be used. The command mode in Java is: Object. Object memberC.color = "Blue";                C.run (); Car C1=NewCar ();    C1.run (); }}
View Code

04-Object-oriented (member variables and local variables). avi

05-Object-oriented (application of anonymous objects). avi

06-Object-oriented (encapsulation overview). avi

07-Object-oriented (encapsulated private). avi

08-Object-oriented (constructor). avi

09-Object-oriented (construction code block). avi

10-Object-oriented (this keyword). avi

11-Object-oriented (app for this keyword). avi

12-Object-oriented (the This keyword is called between constructors). avi

Java Learning day05

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.