A complete java source program should include the following parts:
Package statement; //There is only one sentence in this part at most, which must be placed in the first sentence of the source program.
Import declaration; /* There may or may not be several import statements in this section, and it must be placed before all class definitions */
Public classDefinition// In the definition section of public * * * class, there is at most one public * * * classDefinition. //java language stipulates that the file name of the Java source program must be exactly the same as the public * * * class name. Category definition; //In the class definition section, there can be 0 or more class definitions.
Interface definition; //In the interface definition section, there can be zero or more interface definitions. For example, a java source program can have the following structure. The source program is called Hello World App. Java: Package Java Work. Hello world/* compile everything. Class file to package javawork.helloworld */importjava.awt. *; //Tell the compiler that this program uses the AWT package importjavawork.newcentury of the system; /* Tell the compiler that the user-defined package javawork.newcentury*/
Public class hello world app {...}/* public * * class hello world app, with the same name as the file name */class TheFirstClass {...}// Definition of the first public class, definition of the second class {... definition of the ordinary class ...//Definition of other ordinary class interfaces, first interface {...}/* First interface.
Definition of the first interface */...//Other interface definitions