Java 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
Example
package MyPack;// w w w . j a v a 2 s . c om
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 Enum
- How to create enum type in Java
- Define enum type variable
- Compare two enum values
- An enumeration value can also be used to control a switch statement
Java Class
Java Object
Java Object Reference Variable
Java Methods
Java Method Return
Java Method Parameters
Java Class Constructors
Java Default Constructor
Java Constructor Parameters
Java this Keyword
Java static keyword
Java Method Overload
Java Constructors Overload
Java Method Argument Passing
Java Method Recursion
Java Nested Class
Java Anonymous Classes
Java Local Classes
Java Member Classes
Java Static Member Classes
Java Class Variables
Java main() Method
Java Class Inheritance
Java super keyword
Java Method Overriding
Java Constructor in hierarchy
Polymorphism
Java final keyword
Java Abstract class
Java Class Access Control
Java Package
Java Packages Import
Java Interface
Java Interface as data type
Java interface as build block
Java instanceof operator
Java Object
Java Object Reference Variable
Java Methods
Java Method Return
Java Method Parameters
Java Class Constructors
Java Default Constructor
Java Constructor Parameters
Java this Keyword
Java static keyword
Java Method Overload
Java Constructors Overload
Java Method Argument Passing
Java Method Recursion
Java Nested Class
Java Anonymous Classes
Java Local Classes
Java Member Classes
Java Static Member Classes
Java Class Variables
Java main() Method
Java Class Inheritance
Java super keyword
Java Method Overriding
Java Constructor in hierarchy
Polymorphism
Java final keyword
Java Abstract class
Java Class Access Control
Java Package
Java Packages Import
Java Interface
Java Interface as data type
Java interface as build block
Java instanceof operator