Using Java to implement object-oriented Chapter I.

Source: Internet
Author: User

Chapter One: Abstraction and encapsulation

Class is an abstraction of an object that is an instance of a class

Second, the use of object-oriented design

The process of object-oriented design is an abstract process, which is done in three steps:

1. Find out what kind of it

2. Find out its properties

3. Find out how it behaves

Naming rules for class names, attribute names, method names, and constant names:

1. The class name consists of one or several words, with the first letter of each word capitalized, such as dog, StringBuffer

2. The attribute name and method name consist of one or more words, the first letter is lowercase, the other words are capitalized, such as Health,stuname,println (), GetMessage ().

3. The constant name consists of one or more words, all uppercase letters, such as Pi,sex_male

Four, Static constants

1.static can be used to modify properties, methods, and code blocks

2.static decorated properties and methods are called Class properties (class variables), class methods

3. Properties and methods that do not use static adornments, belong to a single object, often referred to as instance properties (instance variables), instance methods

4.static modified variables and methods can be accessed through the class name and object name, instead of static modified variables and methods can only be accessed through the object name

Static non-private decoration

Non-static, private decoration

Property

Class properties, class variables

Instance properties, instance variables

Method

Class method

Instance method

Calling methods

Class name. properties

Class name. Method ()

Object. Properties

Object. Method ()

Object. Properties

Object. Method ()

Belong

Class

Single Object

5.final can be used to modify properties, methods, and classes

6. The final modified variable becomes constant and its value is fixed

Using Java to implement object-oriented Chapter I.

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.