Older Dick Silk Self-study note--java 0 basics to rookie--014

Source: Internet
Author: User

Object-Oriented: Class, Object, property, method

1. Concept

Class: A set of related properties and behaviors, such as a mobile phone class.

Object: A specific embodiment of a class of things, such as: a Meizu mobile phone.

Properties: The properties of an object, such as the color of a phone.

Methods: The behavior of objects can occur, such as: mobile phone can call.

2. Application

Defines the phone class.

1 //class2 classphone{3     //properties (color)4     intcolor;5     //method (Call)6      Public voidCall (String name) {7SYSTEM.OUT.PRINTLN ("Call" +name+ ");8     }9}

Call the phone class.

1 classfin{2      Public Static voidMain (string[] args) {3         //Object (a mobile phone)4Phone p=NewPhone ();5P.int=0;6P.call ("Zhang San");7     }8 }9 Ten //class is a reference type,output "Call Zhang San"

Older Dick Silk Self-study note--java 0 basics to rookie--014

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.