When we define multiple classes in a source file and there are import statements and package statements, we must pay special attention to the following rules.
1. There can be only one public class in a source file, and there can be multiple non-public classes in a source file;
2. The name of the source file should be the same as the class name of the public class. Keep it consistent;
(Video tutorial recommendation: java video)
For example: the class name of the public class in the source file is People, then the source file should be named People. java.
3. If a class is defined in a package, the package statement should be on the first line of the source file;
4. If the source file contains an import statement, it should be placed in the package statement. and class definition. If there is no package statement, the import statement should be in the first line of the source file;
5. The import statement and package statement are valid for all classes defined in the source file;
6. In the same source file, different package declarations cannot be given to different classes.
Recommended tutorial: Getting started with java development
The above is the detailed content of Introduction to source file declaration rules in java. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment