Implementing object-Oriented Programming with Java (1)

Source: Internet
Author: User

Class--"package

When building a package: standard 3-tier structure
com = company ORG (Corporate or organization)
Jbit = XX (abbreviation of company)
XXXX (no fixed name but you will know what this folder is for)

Shortcut keys

alt+/Tips

Construction method
All classes by default have a constructor method for creating

1. Constructor method method name consistent with class name
2. When an object is created (that is, it is new) the construction method is executed
3. Most of the construction method (more than 90%) is to complete some property assignment ... (Initialize)
4. The system defaults to giving a class A parameterless construction method
5. Once the class is given a constructor method, the method is a parameter, which means the system provides a parameterless construction disappears.

This usage
This invokes the property method construction method in this class

This is allowed in the normal (instance) method. The name of the property and the this. Method name but does not allow this () (called constructor method of this class)
In the constructor method, this () is a call that can be used to construct methods in this class that have and allow only the first line of code in the method body to appear

The variable defined in the normal (instance) method must be appended with the initial value (not giving you no error when you do not call it)
If you don't give an error when you call

static modifier
You can modify----static variable (class variable) class name on a variable. Static variable name
Can be decorated on a normal method--static method (class method) class name. static method Name
Can not be modified on the construction method

static{} static block

The law of execution from top to bottom
1. When the object is created, it executes
2. It is executed when static method static property is called

Packaging
Generalized encapsulation
Narrow encapsulation: Some of the details (attributes) in a hidden class provide methods exposed to provide external access operations

Get set shortcut keys
Alt+shift+s-->get Set--->select all-->ok

If you add final to the variable, it's not going to change what's called a constant.
Normative of a constant name all uppercase letters

Fast generation of construction methods Alt+shift+s Select the third (myeclipse)

Implementing object-Oriented Programming with Java (1)

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.