|
||
| Lesson 2
Objective |
Source files and compilation units
Relationship between Java programs, source files, and compilation units |
|
| Source Code Files
Source files and compilation units
Describe the relationship between Java programs, source files, and compilation units.
You write Java programs by declaring classes and interfaces in source code files, referred to as compilation units. Classes are the cornerstone of Java programs. They declare variables, methods , and constructors .
Interfaces define constants and methods. For a class to implement a particular interface, it must
implement all of the methods that are defined in the interface. A class can define any constant whether or not the constants are already defined in
the interfaces implemented by the class.
Java source code files end with the .java extension and contain at least one class or interface declaration. A source code file may declare, at most,
one public class or interface. If a source code file declares a public class or interface, the file's name must match that of
the class or interface.
|
||
|
|
||