Non-professional Code farmer Java Learning Note 3 Abstraction, encapsulation and Class (2)

Source: Internet
Author: User

(2). static domain-put in memory common storage unit, not placed on specific object, with static modifier

(Continuation of the non-professional code Nong Java Learning Note 3 Abstraction, encapsulation and Class (1) ... )

(3). Static initializer-a set of statements surrounded by a static boot with a pair of curly braces, similar in function to constructors

(4). The final domain-final boot, the value does not change in the whole process

5. Methods

(1) Definition of method: modifier word 1 modifier 2 ... Return value type method name (parameter) throw[exception list]

The personal experience here is to pay attention to the method that defines the return value, to add the return type variable in the method body, and to have the If class select property, you must ensure that the return value is available in all cases.

(2) Abstract method: The method of abstraction modification, only the method header, no curly braces include the method body-can be overridden by a derived method reference, generally similar to the interface; Abstract methods must exist in abstract classes

(3) Static method: A method defined by static that belongs to the entire class

(4) Other methods:

Final method: Final; Local method: Native synchronization method: synchronized

6. Access control-public,private A set of qualifiers that qualify class properties and methods to be accessed and invoked by other parts of the program

(1) Class access control

Public-Decorated class: public class a{}

L public-All classes can be accessed

L protected-class and all subclasses in the package can be accessed

L private-only for use in this class

Default class: Class a{}

L PUBLIC-A all the classes in the package can be used

L PROTECTED-A the class in the package can be used

L private-use only for this class

The problem of modification and mixing doctrine:

L Abstract cannot decorate a class with final

L Abstract cannot be combined with private static final native

L Abstract cannot have private members including fields and methods

L abstract must be in an abstraction class

L static method cannot handle non-static properties

7. The design of the class (a little, the text description is a general talk, only through the hands and slowly explore and learn slowly experience)

process : Defining Classes-(using classes)-creating objects and manipulating objects--(object interaction)--Implementing functions

The next article is inheritance and polymorphism, there are rows to see ....

Non-professional Code farmer Java Learning Note 3 Abstraction, encapsulation and Class (2)

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.