Home > Java > Javagetting Started > What is the package in java

What is the package in java

(*-*)浩
Release: 2019-11-14 13:56:47
Original
11366 people have browsed it

The package in java is actually the folder where the class is located, used to organize java files. Some Java classes with similar functions can be placed in the same package to facilitate organization and calling. Just declare the package with package.

What is the package in java

If you use tools such as Eclipse, you can create the package directly in the project. If you write it manually, you can just create a folder in the project. Write java classes in the folder.

What is a package?                                                                                                                                 (Recommended learning: java course )

In order to better organize classes, Java provides a package mechanism. Packages are containers of classes that separate class namespaces. If no package name is specified, all examples belong to a default unnamed package. Packages in Java generally contain related classes. For example, all classes related to transportation can be placed in a package named Transportation.

What is the purpose of the package?

As mentioned above, better organize classes to prevent duplicate class names in one space; indicate the hierarchical relationship between classes.

How to create a package?

If you don’t use IDE tools, creating a package is just a matter of creating a folder. After creating a new class, just add the package name at the beginning of the class;

It will be more convenient if you use IDE tools. new Package, just specify the package name.

We can define a package while creating a new class. The operation in Eclipse is as follows:

What is the package in java

#

The above is the detailed content of What is the package in java. For more information, please follow other related articles on the PHP Chinese website!

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