Java Series Learning (10)-Package and permission modifiers

Source: Internet
Author: User
Tags modifiers

1. Problems with formal parameters and return values

(1) Formal parameters:

A: Class Name: Objects that require this class

B: Abstract class Name: Sub-class object that needs to be changed

C: Interface Name: An implementation object that requires this interface

(2) Return value type:

A: Class Name: Abstract class Name: Returns the object of the class

B: Abstract class Name: Returns the subclass object of the class

C: Interface Name: Returns the Implementation class object for the interface

(3) Chain-type programming

Each time the method is called, an object is returned

2. Package

(1) is actually a folder

(2) Function:

A: Distinguish between classes of the same name

B: Classification Management of classes

① according to the function of

② according to the module

(3) Definition of package:

①package package name;

② multi-stage ladle. Separate

(4) Precautions:

The A:package statement must be the first in the file

B: In a Java file, there can be only one package

C: If there is no package, the default is the No bag name

(5) Compile and run with package

A: Manual Type

B: Auto-type

"Javac–d. Helloworld.java "

3. Guide Package

(1) Every time we use a class with a package, very troublesome, this time provides a keyword

(2) Format:

A:import Package Name: class name; "Recommended"

B:import Registration: *;

(3) Order of Package,import,class

Package > Import > Class

"The package statement must be the first executable code of the member"

"Package statement can only have one in a Java file"

"If there is no package, default means no packages name"

4. Permission modifiers

5. Common modifiers

(1) Classification:

A: Permission modifier: public,protected, default, private

B: State modifier: static,final

C: Abstraction modifier: Abstract

(2) A common class is a modifier of its composition

A: Class

① default: Public, Final,abstract

② Common: Public

B: Member variables

① default: public,protected, Default, private,static,final

② Common: Private

C: Construction method

① default: public,protected, default, private

② Common: Public

C: Member Method

① default: public,protected, Default, Private,static,final,abstract

② Common: Public

(3) The other more common

public static final int X = 10;//static constant

public static void Show () {};//static method

Public final void Show () {};//The method cannot be overridden

public abstract void Show ();//abstract method

Java Series Learning (10)-Package and permission modifiers

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.