Source Files
In this chapter you will learn:
Java Source File
All Java source files must end with the .java extension. A source file should contain, at most, one top-level public class definition. If a public class is present, the class name should match the unextended filename.
Three top-level elements known as compilation units may appear in a file. None of these elements is required.
If they are present, then they must appear in the following order:
- Package declaration
- Import statements
- Class, interface, and enum definitions
package MyPack;/* java 2 s . com*/
import java.util.Date;
public class Main {
public static void main(String args[]) {
System.out.println(new Date());
}
}
Next chapter...
What you will learn in the next chapter:
- What is Java access control level
- What is default access control level
- How does the access control act on the inheritance
- What is the access matrix for Java
- What are the targets for different access modifiers
Home » Java Tutorial » Class Creation