Package-info.java

Source: Internet
Author: User

First, it cannot be created.In eclipse, the package-info file cannot be created at will. The "type name is notvalid" error is reported, and the class name is invalid. The Java variable definition specification is: letters, numbers, and underscores, there is also the less commonly used $ symbol (by the way, Java is a variable that supports Chinese names. If you are used to the challenge, you can try and share your experience in this area ), how can I create this file?

It's easy to use NotePad to create one, copy it, and then change it. The more direct way is to copy one from another project, which is more convenient.

Second, the service objects are very special.A class is the description of a class or a group of things. For example, the dog class describes wangcai. What is the description of the package-Info class? It always has an object to be described or presented. It isDescribe and record the package information.

Finally, the class cannot have public or private access permissions.Package-info.java how special, is also a class file, will be compiled into a package-info.class, but in the package-info.java can only declare the default access to the class, that is, friendly class.

In fact, there are several special aspects, such as the inability to inherit, the absence of interfaces, and the absence of inter-class relationships (associations, combinations, and aggregation.

The particularity of this file is over. Let's talk about its role. It has three roles:

1. Facilitate Annotation on the package;

2. Declare friendly classes and package constants;

3. Provide an overall description of the package.

1 ./**
* <B> package-info is not a common class and has three functions: </B> <br>
* 1. Convenience of Annotation on the package; <br>
* 2. Declare the private class and constant of the package. <br>
* 3. Provide an overall description of the package. <Br>
*/
Package com. Company;

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.