Home > Java > javaTutorial > body text

Regaining the basics of Java (10): Summary of the concept of packages

黄舟
Release: 2017-01-16 09:48:59
Original
1856 people have browsed it

Regaining the Basics of Java (10): Summary of the Concept of Packages

1. The Concept of Packages

1. A package refers to a folder created during Java compilation in order to distinguish the subdivisions of each module in Java.

2. The package is usually filled with bytecode files (.class) generated after compiling the class.

3. The naming of the package is usually the company domain name. Project name. Module name ( com.taobao.denglu.*)

2. Create a package

1. Creating a package is generally created starting from the current folder.

2. Create a package using the package name.

3. If you do this: package cn.aa.bb Then create the cn folder starting from the current folder. The cn folder includes the aa folder. The aa folder includes the bb folder.

4. Create a package: It is not recommended to create a folder directly on the hard disk and compile javac -d TestPackage.java with the package (you can also write the path after -d, so that it will be built in the path you specified)

5. Run with package: Class name of the class with package: package name. Class name abc.TestPackage Full name of class name

6. Must comply with identifier regulations and cannot start with a dot Or end

7. See the name and know the meaning a.b.c

3. Import package

#1. The import package is a certain one in java package to call classes and methods in another package. At this time, you must import the package path of the class you want to call.

2. Use the import keyword to import packages. But please note that the paths are connected with (dots in English).

3. import package name.class name

;4. Sequence: Declare package>Import package>Definition class

4. Visit the decoration

# 1, decorative category:

A, PUBLIC Unlimited Import Import, you can use

#ser Can be called * Public

2 is generally used in front of the class. Modification method. Use

C, default modifier package permissions

D, private class permissions

Regaining the basics of Java (10): Summary of the concept of packages

Regaining the basics of Java (10): Summary of the concept of packages

Regaining the basics of Java (10): Summary of the concept of packages

Regaining the basics of Java (10): Summary of the concept of packages#6. Local classes

Local variables: variables defined in a method

    2. Local inner class: a class defined in a method
  1. 3. The scope of use of a local inner class is the same as that of a local variable

  2. 4. When a method in a local inner class is called, its position is as follows Figure

Regaining the basics of Java (10): Summary of the concept of packages##7. Anonymous inner classes (key points)

Anonymous object Object without name

2. Internal class without name
  1. 3. Prerequisite: This class must inherit a class , or implements an interface (only one interface can be implemented) The anonymous inner class cannot provide a constructor

The above is to regain the basics of java (10) : Summary of the concept of packages. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template