Java file structure and precautions

zhaozj2021-02-16  48

Java file structure and precautions

1. Java's program is organized, and there are multiple classes in a file, but you want a class that can be launched directly, this class must have a MIAN function, one program can only have a MAIN function.

2. Class name can be added to the public keyword, or you can not add, add the file name saved in the future, you must have the same name as this class, otherwise the compile will be wrong, if you don't add public, there is no requirement. A source file can only be included in a class labeled as public.

There are multiple classes definitions in a file that generates a plurality of byte stream files corresponding to these class names after compiling such source files.

3. When the Java XXX runs, the XXX is a class name instead of a file name. XXX is a class name containing the main function. The XXX is not the same as the file name after compiling.

转载请注明原文地址:https://www.9cbs.com/read-21592.html

New Post(0)